- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
List all VM's in a virtual centre running windows XP OS
Is it possible to get a script which will list all VM's in a virtual centre which is running windows XP OS. And also which vmware datacentre they are in.
That would be great to have in a csv format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This should help in exactly what you want.. Just you need to work on CSV file alignment little-bit.. ![]()
Refer the to the command section of this article (Step-3).
Get-VM | select Name, Guest | Export-CSV D:\test.csv
It should do for you. I am not sure if Datacentre column can be fit in the report.. will try and let you know..
Thanks,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, so here is the command you can use to get the VM Name, Guest OS Details and Datacenter Details...
Get-VM | Select Name, Guest, @{N="Datacenter";E={Get-Datacenter -VM $_}}
To export the result in CSV, you can use it like below:
Get-VM | Select Name, Guest, @{N="Datacenter";E={Get-Datacenter -VM $_}} | Export-Csv D:\Test.CSV
Thanks,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the replies.
Is there anyway we can list out only the VM's with windows XP OS, as the above scripts lists out all VM's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try like this
Get-VM |
where{$_.Guest.OSFullName -match "XP"} |
Select Name,@{N='GuestOS';E={$_.Guest.OSFullName}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may try below one, should work for filtering only "Windows Xp" guest VMs.
--------------------------------------------------------------------------------------------------------------------------
$vms = Get-VM
Foreach ($vm in $vms){
if ((Get-View $vm).Guest.GuestFullName -match "windows xp"){
Write-Host $vm.Name, " => " , (Get-View $vm).Guest.GuestFullName
}
}
--------------------------------------------------------------------------------------------------------------------------
You can check keeping "Xp" instead of "Windows Xp", it should also work..
Thanks,
Amit