pasalott
Enthusiast
Enthusiast

Powershell script to list VMs with attached iso

I have a simple powershell script for listing VMs with attached iso's.  I would like to add a column for vCenter server but not exactly sure what cmdlet to use.

Connect-VIServer [vcenter1],[vcenter2],[vcenter3],[vcenter4] -User [username] -Password [password]
Get-VM | Get-CDDrive | select @{N=”VM”;E=”Parent”},IsoPath | where {$_.IsoPath -ne $null} | Export-Csv -Path “C:\Temp\VMs_ISOs.csv” -NoTypeInformation -UseCulture

 

 

Reply
0 Kudos
LucD
Leadership
Leadership

Try like this

Get-VM | Get-CDDrive |
Where-Object { $_.IsoPath -ne $null } |
Select-Object @{N = 'VM'; E = {$_.Parent.Name }}, IsoPath,
@{N = 'vCenter'; E = { ([uri]($_.Parent.ExtensionData.Client.ServiceUrl)).Host } }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
pasalott
Enthusiast
Enthusiast

That worked.  Thanks

Reply
0 Kudos