Hello Everyone,
I'm looking to schedule the Bulk lists of VM's to upgrade HW version at a particular time through power cli. Kindly help.
thanks
vmk2014
Ok, that explains the error.
Hardware version 13 requires ESXi 6.5.
With ESXi 5.5, which is not supported anymore btw, the highest supported HW version is V10.
See KB1003746
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I did upgrade to Version 10 and it worked.
Just to confirm since i dont have any more test VM's left so the modified script will work ? I'll try to get more test VM's.
$vmNames = Get-Content -Path C:\TEMP\vmliste.txt | where{$_ -ne ''}
# Select powered off VM and powered on VMs that have VMware Tools running
$vms = Get-VM -Name $vmNames | where{$_.PowerState -eq 'PoweredOff' -or
($_.PowerState -eq 'PoweredOn' -and $_.Guest.State -eq 'running')}
# Shutdown all powered on VMs from list
$vms | where{$_.PowerState -eq 'PoweredOn'} | Shutdown-VMGuest -Confirm:$false
# Wait till all VMs are shutdown
while((Get-VM -Name $vms.Name | Select -ExpandProperty PowerState) -contains 'PoweredOn'){
sleep 5
}
# Set new HW version and start VM
Get-VM -Name $vms.Name | Set-VM -Version v13 -Confirm:$false | Start-VM -Confirm:$false
Thanks
vmk
Provided the VMs involved are all running on an ESXi 6.5, yes, that should work.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sound good. Thank you for your effort.
Thanks
vmk
LucD,
Slight modification is needed on this. We want only powered on vM's should be upgraded while running the script.
Please let me know where i need to modify.We dont want to power on the powered off VM's due to some reason.
thanks
vmk
This should do the trick.
$vmNames = Get-Content -Path C:\TEMP\vmliste.txt | where{$_ -ne ''}
# s that have VMware Tools running
$vms = Get-VM -Name $vmNames | where{$_.PowerState -eq 'PoweredOn' -and $_.Guest.State -eq 'running'}
if($vms){
# Shutdown all powered on VMs from list
$vms | Shutdown-VMGuest -Confirm:$false
# Wait till all VMs are shutdown
while((Get-VM -Name $vms.Name | Select -ExpandProperty PowerState) -contains 'PoweredOn'){
sleep 5
}
# Set new HW version and start VM
Get-VM -Name $vms.Name | Set-VM -Version v13 -Confirm:$false | Start-VM -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Can we include snapshot also in the script before upgrading the HW version ? Since we are upgrading the VM's in bulk so incase require revert we can do later on.
thanks
vmk
Sure, you could do something like this
$vmNames = Get-Content -Path C:\TEMP\vmliste.txt | where{$_ -ne ''}
# Select powered off VM and powered on VMs that have VMware Tools running
$vms = Get-VM -Name $vmNames | where{$_.PowerState -eq 'PoweredOff' -or
($_.PowerState -eq 'PoweredOn' -and $_.Guest.State -eq 'running')}
# Shutdown all powered on VMs from list
$vms | where{$_.PowerState -eq 'PoweredOn'} | Shutdown-VMGuest -Confirm:$false
# Wait till all VMs are shutdown
while((Get-VM -Name $vms.Name | Select -ExpandProperty PowerState) -contains 'PoweredOn'){
sleep 5
}
Get-VM -Name $vms.Name | New-Snapshot -Name 'HWUpgrade' -Description 'HW Upgrade' -Confirm:$false
# Set new HW version and start VM
Get-VM -Name $vms.Name | Set-VM -Version v13 -Confirm:$false | Start-VM -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Awesome !!. First of all, i would like to say thank you for your prompt help. I'll test and let you know.
thanks
vmk