1 2 3 4 Previous Next 48 Replies Latest reply on Dec 5, 2018 10:09 PM by vmk2014 Go to original post
      • 15. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
        vmk2014 Hot Shot

        Here you go :-

         

         

        PS C:\temp> .\VM-HW.ps1

        5

        Get-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not

        null or empty, and then try the command again.

        At C:\temp\VM-HW.ps1:7 char:14

        + Get-VM -Name $vmNames

        +              ~~~~~~~~

            + CategoryInfo          : InvalidData: (:) [Get-VM], ParameterBindingValidationException

            + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

         

         

        thanks

        vmk

        • 16. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          I did several tests, and the only way I can reproduce the error you are getting, is by placing a blank line at the start of the .txt file.

          Can run the following and check if the 1st number is a 0 (zero)?

           

          Get-Content -Path C:\TEMP\vmliste.txt |

          ForEach-Object -Process {

              $_.Length

          }

           

          • 17. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
            vmk2014 Hot Shot

            LucD,

             

            Please find the output after giving the bove command.

             

            PS C:\temp> .\VM-HW.ps1

            9

            13

            14

            14

            0

             

            This project is important for me because we cant get down time for all VM's in shot, hence trying script.

             

            thanks

            vmk

            • 18. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
              vmk2014 Hot Shot

              LucD,

               

              I tried as suggested leaving first line blank

               

              PS C:\temp> .\VM-HW.ps1

              0

              Get-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not

              null or empty, and then try the command again.

              At C:\temp\VM-HW.ps1:17 char:14

              + Get-VM -Name $vmNames | Shutdown-VMGuest -Confirm:$false

              +              ~~~~~~~~

                  + CategoryInfo          : InvalidData: (:) [Get-VM], ParameterBindingValidationException

                  + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

               

               

              Get-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not

              null or empty, and then try the command again.

              At C:\temp\VM-HW.ps1:23 char:21

              + while((Get-VM -Name $vmNames | Select -ExpandProperty PowerState) -co ...

              +                     ~~~~~~~~

                  + CategoryInfo          : InvalidData: (:) [Get-VM], ParameterBindingValidationException

                  + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

               

               

              Get-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not

              null or empty, and then try the command again.

              At C:\temp\VM-HW.ps1:33 char:14

              + Get-VM -Name $vmNames | Set-VM -Version v13 -Confirm:$false | Start-V ...

              +              ~~~~~~~~

                  + CategoryInfo          : InvalidData: (:) [Get-VM], ParameterBindingValidationException

                  + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

               

               

              Infact, i  did tried 2nd script given by you initially, but no results except below error

               

              PS C:\temp> .\VM-HW2.ps1

               

               

              Type Value

              ---- -----

              Task task-9593806

              Task task-9593807

              Task task-9593808

              Task task-9593809

              Get-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not

              null or empty, and then try the command again.

              At C:\temp\VM-HW2.ps1:3 char:24

              +     $vm = Get-VM -Name $vmlist

              +                        ~~~~~~~

                  + CategoryInfo          : InvalidData: (:) [Get-VM], ParameterBindingValidationException

                  + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

               

               

              Task task-9593810

               

              Thanks

              vmk

              • 19. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                LucD Guru
                Community WarriorsUser ModeratorsvExpert

                Ok, I think I know what is happening.

                Your .txt file obviously contains 5 lines, and the 4 first lines have a valid VM name on them.

                In the original script I used the _Task form of the method, which is why you see the Task lines as output.

                These tasks are run in the background, hence the Task reference.

                 

                The error happens after 4 background tasks, that is obviously the 5 entry, which is a blank line.
                This is also confirmed by the 0 length I saw in the output of the snippet I asked you to run.

                 

                To avoid the blank lines causing the errors you are seeing, I added a test after the Get-Content cmdlet.

                Give this one a try

                 

                 

                $vmNames = Get-Content -Path C:\TEMP\vmliste.txt | where{$_ -ne ''}

                 

                # Shutdown all VMs from list

                Get-VM -Name $vmNames | Shutdown-VMGuest -Confirm:$false

                 

                # Wait till all VMs are shutdown

                while((Get-VM -Name $vmNames | Select -ExpandProperty PowerState) -contains 'PoweredOn'){

                    sleep 5

                }

                 

                # Set new HW version and start VM

                Get-VM -Name $vmNames | Set-VM -Version v13 -Confirm:$false | Start-VM -Confirm:$false

                • 20. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                  vmk2014 Hot Shot

                  LucD,

                   

                  Thanks for finding. Now slight improvement now but error shows

                   

                   

                   

                  PS C:\> cd temp

                  PS C:\temp> .\VM-HW.ps1

                   

                   

                  State          IPAddress            OSFullName

                  -----          ---------            ----------

                  Running        {2002:9f6c:23b9::... Microsoft Windows Server 2008 R2 (64-bit)

                  Shutdown-VMGuest : 12/04/2018 12:14:12 AM       Stop-VMGuest            Operation "Shutdown VM guest." failed for VM "cb

                  vwt-iimss18d"

                  for the following reason: Cannot complete operation because VMware Tools is not running in this virtual machine.

                   

                   

                  At C:\temp\VM-HW.ps1:9 char:25

                  + Get-VM -Name $vmNames | Shutdown-VMGuest -Confirm:$false

                  +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                      + CategoryInfo          : NotSpecified: (:) [Stop-VMGuest], VimException

                      + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_ShutdownVmGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.

                     Commands.StopVmGuest

                   

                   

                  Running        {159.108.37.178, ... Microsoft Windows Server 2012 (64-bit)

                  Shutdown-VMGuest : 12/04/2018 12:14:12 AM       Stop-VMGuest            Operation "Shutdown VM guest." failed for VM "cb

                  vwt-iimss17d"

                  for the following reason: Cannot complete operation because VMware Tools is not running in this virtual machine.

                   

                   

                  At C:\temp\VM-HW.ps1:9 char:25

                  + Get-VM -Name $vmNames | Shutdown-VMGuest -Confirm:$false

                  +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                      + CategoryInfo          : NotSpecified: (:) [Stop-VMGuest], VimException

                      + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_ShutdownVmGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.

                     Commands.StopVmGuest

                   

                  Thanks

                  vmk

                  • 21. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                    vmk2014 Hot Shot

                    LucD,

                     

                    I believe, if the VMware tools is not installed or out of date then the script will not work. Can we put clause that if vmware tools not installed or out of date then it will install first and then update

                    VM HW versions.

                     

                     

                    Thanks

                    vmk

                    • 22. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                      LucD Guru
                      User ModeratorsvExpertCommunity Warriors

                      Yes, to use the *Guest cmdlets, you need the VMware Tools to be installed.

                      Updating the VMware Tools is builtin, installing from scratch requires more.

                      Which types of guest OS are we looking at?

                      A mix of Windows and Linux?

                      • 23. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                        vmk2014 Hot Shot

                        LucD,

                         

                        It's upgrading HW to 13, but with error on the screen. Can we remove the below error.

                         

                         

                         

                        PS C:\temp> .\VM-HW.ps1

                         

                         

                        State          IPAddress            OSFullName

                        -----          ---------            ----------

                        Running        {150.x.x.121, ... Microsoft Windows Server 2012 (64-bit)

                        Running        {150.x.x.119, ... Microsoft Windows Server 2012 (64-bit)

                        Get-VM : 12/04/2018 12:43:56 AM Get-VM          VM with name '#cxv-txm1d' was not found using the specified filter(s).

                         

                         

                        At C:\temp\VM-HW.ps1:9 char:1

                        + Get-VM -Name $vmNames | Shutdown-VMGuest -Confirm:$false

                        + ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:43:56 AM Get-VM          VM with name '#VM4' was not found using the specified filter(s

                        ).

                        At C:\temp\VM-HW.ps1:9 char:1

                        + Get-VM -Name $vmNames | Shutdown-VMGuest -Confirm:$false

                        + ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:43:56 AM Get-VM          VM with name '#VM5' was not found using the specified filter(

                        s).

                        At C:\temp\VM-HW.ps1:9 char:1

                        + Get-VM -Name $vmNames | Shutdown-VMGuest -Confirm:$false

                        + ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:43:56 AM Get-VM          VM with name '#VM3' was not found using the specified filter(

                        s).

                        At C:\temp\VM-HW.ps1:9 char:1

                        + Get-VM -Name $vmNames | Shutdown-VMGuest -Confirm:$false

                        + ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:43:58 AM Get-VM          VM with name 'cxv-txm1d' was not found using the specified filter(s).

                         

                         

                        At C:\temp\VM-HW.ps1:15 char:8

                        + while((Get-VM -Name $vmNames | Select -ExpandProperty PowerState) -co ...

                        +        ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:43:58 AM Get-VM          VM with name '#VM2' was not found using the specified filter(s

                        ).

                        At C:\temp\VM-HW.ps1:15 char:8

                        + while((Get-VM -Name $vmNames | Select -ExpandProperty PowerState) -co ...

                        +        ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:43:58 AM Get-VM          VM with name '#cbvwt-iimxyzd' was not found using the specified filter(

                        s).

                        At C:\temp\VM-HW.ps1:15 char:8

                        + while((Get-VM -Name $vmNames | Select -ExpandProperty PowerState) -co ...

                        +        ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:43:58 AM Get-VM          VM with name '#cbvwt-iimxyz9d' was not found using the specified filter(

                        s).

                        At C:\temp\VM-HW.ps1:15 char:8

                        + while((Get-VM -Name $vmNames | Select -ExpandProperty PowerState) -co ...

                        +        ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:44:05 AM Get-VM          VM with name '#cbx-txm1d' was not found using the specified filter(s).

                         

                         

                        At C:\temp\VM-HW.ps1:15 char:8

                        + while((Get-VM -Name $vmNames | Select -ExpandProperty PowerState) -co ...

                        +        ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:44:05 AM Get-VM          VM with name 'cbvwt-iimxy10d' was not found using the specified filter(s

                        ).

                        At C:\temp\VM-HW.ps1:15 char:8

                        + while((Get-VM -Name $vmNames | Select -ExpandProperty PowerState) -co ...

                        +        ~~~~~~~~~~~~~~~~~~~~~

                            + CategoryInfo          : ObjectNotFound: (:) [Get-VM], VimException

                            + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

                         

                         

                        Get-VM : 12/04/2018 12:44:05 AM Get-VM          VM with name 'ccbvwt-iimxy10d' was not found using the specified filter(

                        s).

                         

                        thanks

                        vmk

                        • 24. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                          vmk2014 Hot Shot

                          LucD,

                           

                          Please find my answer

                           

                          Yes, to use the *Guest cmdlets, you need the VMware Tools to be installed.- Understood, that it require vmware tools inorder to cmdlet function to work

                          Updating the VMware Tools is builtin, installing from scratch requires more. Can we ignore and proceed further if the script finds VMware tools missing or not installed.

                          Which types of guest OS are we looking at? Only Windows 2008,2012 and 2016

                          A mix of Windows and Linux?  Only Windows 2008,2012 and 2016

                           

                          Thanks

                          vmk

                          • 25. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                            LucD Guru
                            vExpertUser ModeratorsCommunity Warriors

                            It looks as if for a number of the names in the CSV, the VM can not be found.
                            Are you connected to a vCenter?
                            Did you check if the names are correct?
                            Does a Get-VM work for all the names in the list?

                            • 26. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                              vmk2014 Hot Shot

                              LucD,

                               

                              All VM's names are correct, just i tweaked it in post in order to hide the VM's name.

                               

                              Also, does the script will work if the VMware tools is out of date ? Please confirm  or only if the VMware tools is not installed it will not work.

                               

                              Thanks

                              vmk

                              • 27. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                                vmk2014 Hot Shot

                                Sorry, i missed out to answer last questions. Does a Get-VM work for all the names in the list?

                                 

                                PS C:\temp>

                                PS C:\temp> Get-VM VM1

                                 

                                 

                                Name                 PowerState Num CPUs MemoryGB

                                ----                 ---------- -------- --------

                                VM1       PoweredOn  2        4.000

                                 

                                 

                                PS C:\temp> Get-VM VM2

                                 

                                 

                                Name                 PowerState Num CPUs MemoryGB

                                ----                 ---------- -------- --------

                                VM2       PoweredOn  2        4.000

                                 

                                Thanks

                                vmk

                                • 28. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                                  LucD Guru
                                  vExpertUser ModeratorsCommunity Warriors

                                  That is not what the errors are saying.
                                  They clearly state that the VMs with those names are not found.
                                  You can check again with

                                   

                                  $vmNames = Get-Content -Path C:\TEMP\vmliste.txt | where{$_ -ne ''}

                                  Get-VM -Name $vmNames

                                   

                                  When the VMware Tools are out of date, but running, the Shutdown-VMGuest should work.

                                  • 29. Re: Scheduling the Bulk VM's Hardware version upgrade in ESXi host 6.5 through power cli
                                    vmk2014 Hot Shot

                                    You are right one of the VM's was incorrect or not able to find not sure hwy but its in VC.

                                     

                                     

                                     

                                    PS C:\temp> .\test.ps1

                                     

                                     

                                    Name                 PowerState Num CPUs MemoryGB

                                    ----                 ---------- -------- --------

                                    VM1       PoweredOn  2        4.000

                                    VM2      PoweredOn  2        4.000