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

11 Comments

  1. After examine a number of of the weblog posts in your web site now, and I truly like your method of blogging. I bookmarked it to my bookmark web site list and will be checking again soon. Pls take a look at my web site as properly and let me know what you think.

  2. Good day! This is my first visit to your blog! We are a team of volunteers and starting a new project in a community in the same niche. Your blog provided us valuable information to work on. You have done a extraordinary job!

  3. You can definitely see your enthusiasm in the work you write. The world hopes for more passionate writers like you who aren’t afraid to say how they believe. Always follow your heart.

Leave a Reply

Your email address will not be published.