- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That worked. Thanks