PowerCLI

 View Only
  • 1.  Powershell script to list VMs with attached iso

    Posted Aug 01, 2022 07:44 PM

    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

     

     



  • 2.  RE: Powershell script to list VMs with attached iso
    Best Answer

    Posted Aug 01, 2022 07:52 PM

    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 } }


  • 3.  RE: Powershell script to list VMs with attached iso

    Posted Aug 01, 2022 08:22 PM

    That worked.  Thanks