Starting all the VMs in the folder 'production1'
$vms = Get-VM -Location production1
ForEach($vm in $vms) # Start each VM in the folder 'production1'
{
start-vm -RunAsync -VM $vm -Confirm:$false
}
Stopping all the VMs in the folder 'production1'
$vms = Get-VM -Location production1
ForEach($vm in $vms)
# Try a graceful shutdown of VMGuest if vmware tools are installed, Otherwise just stop the VM
{
$vm_view = $vm | get-view
$vmtoolsstatus = $vm_view.summary.guest.toolsRunningStatus
Write-Host “VM $vm says tools status is $Vmtoolsstatus”
if ($vmtoolsstatus -eq “guestToolsRunning”)
{
Shutdown-VMGuest -VM $vm -Confirm:$false # Shutting down VMGuest gracefully
}
else
{
Stop-VM -RunAsync -VM $vm -Confirm:$false # Stopping the VM
}
}
$vms = Get-VM -Location production1
ForEach($vm in $vms) # Start each VM in the folder 'production1'
{
start-vm -RunAsync -VM $vm -Confirm:$false
}
Stopping all the VMs in the folder 'production1'
$vms = Get-VM -Location production1
ForEach($vm in $vms)
# Try a graceful shutdown of VMGuest if vmware tools are installed, Otherwise just stop the VM
{
$vm_view = $vm | get-view
$vmtoolsstatus = $vm_view.summary.guest.toolsRunningStatus
Write-Host “VM $vm says tools status is $Vmtoolsstatus”
if ($vmtoolsstatus -eq “guestToolsRunning”)
{
Shutdown-VMGuest -VM $vm -Confirm:$false # Shutting down VMGuest gracefully
}
else
{
Stop-VM -RunAsync -VM $vm -Confirm:$false # Stopping the VM
}
}
No comments:
Post a Comment