Hi Everyone,
This is what I am trying to find if anyone could help, that would be great.
1. A script to shutdown certain VMGuests. (Only VMguests from a list I provide)
2. the upgrade of hardware for the sames guests
3. Power on after hardware upgrade is complete
You could do something like this.
The .txt file contains the vm names, one per line.
$vmNames = Get-Content -Path vmnames.txt
$vms = Get-VM -Name $vmNames
foreach($vm in $vms){
Stop-VMGuest -VM $vm
while($vm.PowerState -ne 'PoweredOff'){
$vm = Get-VM -Name $vm.Name
sleep 5
}
Set-VM -VM $vm -Version v10 -Confirm:$false
Start-VM -VM $vm -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do something like this.
The .txt file contains the vm names, one per line.
$vmNames = Get-Content -Path vmnames.txt
$vms = Get-VM -Name $vmNames
foreach($vm in $vms){
Stop-VMGuest -VM $vm
while($vm.PowerState -ne 'PoweredOff'){
$vm = Get-VM -Name $vm.Name
sleep 5
}
Set-VM -VM $vm -Version v10 -Confirm:$false
Start-VM -VM $vm -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Luc,
This script is awesome. Thank You. Onyly one question though. I have tested this on one VM, and it prompted me for a response to perform the action of shutting down, if which I had to ansewr YES. If I have multiple VMs, would I have to repeat answering for each VM? Alternately, is there a force response that could be added to the script
I hope that makes sense
figured it out with -Confirm$false
Thanks again