Useful scripts to upgrade the virtual hardware of VMs from a list

If you plan to upgrade the virtual hardware (vHW) of a large number of virtual machines from a list, the following PowerCLI scripts may be useful for you.

All code-snippets are processing the virtual machines listed in a text file „C:\temp\vmliste.txt“

The scripts will help you to perform the following actions:

  • shutdown all VMs from the list
  • upgrade the virtual Hardware to the desired version (eg. 11)
  • power-on all VMs from the list

Part 1 – Shutdown all VMs from the list „C:\temp\vmliste.txt“

 

foreach($vmlist in (Get-Content -Path C:\TEMP\vmliste.txt)){
$vm = Get-VM -Name $vmlist
Shutdown-VMGuest -VM $vm -Confirm:$false
}

Part 2 – Upgrade the vHW to the desired version (eg. 11):

 

foreach($vmlist in (Get-Content -Path C:\TEMP\vmliste.txt)){
$vm = Get-VM -Name $vmlist
Set-VM -VM $vm -Version v11 -Confirm:$false
}

Part 3 – Start all VMs from the list „C:\temp\vmliste.txt“

 

foreach($vmlist in (Get-Content -Path C:\TEMP\vmliste.txt)){
$vm = Get-VM -Name $vmlist
Start-VM -VM $vm -Confirm:$false
}

Leave a Comment

Your email address will not be published. Required fields are marked *