Contributor
Contributor

Edit VM Startup/Shutdown Configuration

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
Leadership
Leadership

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

0 Kudos
3 Replies
Leadership
Leadership

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

0 Kudos
Contributor
Contributor

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

0 Kudos
Leadership
Leadership

Oops, typo.
The code above is corrected


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

0 Kudos