Power Off listed VM’s
Connect to Vcenter
Connect-VIServer vmwareenterprise.com -WarningAction 0
####### Shutdown all VMs from the list “C:\temp\vm.txt“###########
foreach($vmlist in (Get-Content -Path C:\TEMP\vm.txt))
{
$vm = Get-VM -Name $vmlist
Shutdown-VMGuest -VM $vm -Confirm:$false
}
####### Generate CSV report with powerstate of listed vm’s ##########
$powerstate = @()
foreach($vmlist in (Get-Content -Path C:\temp\vm.txt)){
$vm = Get-VM -Name $vmlist
$powerstate += (Get-VM $vm |
Select Name,PowerState,
@{N=’VMHost’;E={$_.VMHost.Name}})
}
$powerstate | Export-Csv -Path C:\temp\powerstate_report.csv -NoTypeInformation -UseCulture