hello guys..
Here is the script to update the vm hardware for list of VM’s
$vms=Get-Content C:\Temp\servers.txt foreach($MyVM in $vms){ Write-Host "========Before Upgrading===================" -ForegroundColor Yellow $MyVM = Get-VM -Name vm10 Write-Host $MyVM.Name $MyVM.Version -ForegroundColor White if ($MyVM.PowerState -eq "PoweredOn") { Write-Host "Shutting Down" $MyVM Stop-VMGuest -VM $MyVM -Confirm:$false do { Start-Sleep -s 5 $MyVMStat = Get-VM -Name $MyVM $status = $MyVMStat.PowerState }until($status -eq "PoweredOff") $snapTask=New-Snapshot -VM $MyVM -Name HardwareUpgrade -RunAsync Wait-Task $snapTask $snapState= Get-Task -Id $snaptask.Id |Select State,VM if($snapState.State -eq "Success"){ Write-Host $MyVM "Snapshot is created and proceeding for Hardware Upgrade" #Get-Snapshot -VM $MyVM|Select Name,Created $vmversiontask=Set-VM -VM $MyVM -Version v10 -Confirm:$false -RunAsync $wtask=Wait-Task $vmversiontask write-host $wtask.Id,$vmversiontask.Id $state=Get-Task |Select-Object * |where{($_.ObjectId -eq $wtask.Id) -and ($_.Name -eq "UpgradeVM_Task")} } } Write-Host "================After the hardware Upgrade===========" -ForegroundColor Yellow Write-Host $MyVM.Name $MyVM.Version -ForegroundColor White }