3 Replies Latest reply on Oct 17, 2020 8:35 AM by LucD

    Edit VM Startup/Shutdown Configuration

    aryajp Lurker

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

        • 1. Re: Edit VM Startup/Shutdown Configuration
          LucD Guru
          Community WarriorsvExpertUser Moderators

          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: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Edit VM Startup/Shutdown Configuration
            aryajp Lurker

            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

            • 3. Re: Edit VM Startup/Shutdown Configuration
              LucD Guru
              User ModeratorsvExpertCommunity Warriors

              Oops, typo.
              The code above is corrected

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz