VMware Cloud Community
aryajp
Contributor
Contributor
Jump to solution

Edit VM Startup/Shutdown Configuration

what is the powercli command to move all manual startup vms to automatic in a particular Esxi Server.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can do something like this, but be aware that VMHostAutoStartPolicy needs to be enabled to be able to do that.
You can check with Get-VMHostStartPolicy and eventually change with Set-VMHostSTartPolicy.

$esxName = 'MyEsx'

Get-VMHost -Name $esxName |

Get-VM | Get-VMStartPolicy | where{$_.StartAction -eq 'None'} |

Set-VMStartPolicy -StartAction PowerOn -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

You can do something like this, but be aware that VMHostAutoStartPolicy needs to be enabled to be able to do that.
You can check with Get-VMHostStartPolicy and eventually change with Set-VMHostSTartPolicy.

$esxName = 'MyEsx'

Get-VMHost -Name $esxName |

Get-VM | Get-VMStartPolicy | where{$_.StartAction -eq 'None'} |

Set-VMStartPolicy -StartAction PowerOn -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
aryajp
Contributor
Contributor
Jump to solution

Hi LucD,

Getting below error:

Where-Object : Cannot validate argument on parameter 'Property'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

At C:\Users\Administrator\Documents\WindowsPowerShell\VMAuto-Start.ps1:3 char:35

+ Get-VM | Get-VMStartPolicy | where{}$_.StartAction -eq 'None' |

+                                   ~~

    + CategoryInfo          : InvalidData: (:) [Where-Object], ParameterBindingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.WhereObjectCommand

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Oops, typo.
The code above is corrected


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos