how to i find if my list of vms have usb/floppy/cdrom attached?
The Filter parameter on the Get-View cmdlet accepts a RegEx on the right-hand side.
You can use the RegEx or operator.
$vmNames = (Get-Content -Path .\vmnames.txt) -join '|'
Get-View -ViewType VirtualMachine -Property Name,'Config.Hardware' -Filter @{Name=$vmNames} |
Where-Object { $_.Config.Hardware.Device.Where({$_.gettype().name -match 'VirtualUSBController'}) } |
Select-Object -ExpandProperty Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Use a script
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
how do i feed my list of vms from txt file to this?
Get-View -ViewType VirtualMachine -Property Name,'Config.Hardware' | Where-Object { $_.Config.Hardware.Device.Where({$_.gettype().name -match 'VirtualUSBController'}) } | Select-Object -ExpandProperty Name
The Filter parameter on the Get-View cmdlet accepts a RegEx on the right-hand side.
You can use the RegEx or operator.
$vmNames = (Get-Content -Path .\vmnames.txt) -join '|'
Get-View -ViewType VirtualMachine -Property Name,'Config.Hardware' -Filter @{Name=$vmNames} |
Where-Object { $_.Config.Hardware.Device.Where({$_.gettype().name -match 'VirtualUSBController'}) } |
Select-Object -ExpandProperty Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
nice. Thanks Luc