VMware Cloud Community
tdubb123
Expert
Expert
Jump to solution

how to i find if my list of vms have usb/floppy/cdrom attached?

how to i find if my list of vms have usb/floppy/cdrom attached?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

4 Replies
LucD
Leadership
Leadership
Jump to solution

Use a script


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

0 Kudos
tdubb123
Expert
Expert
Jump to solution

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
 
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

tdubb123
Expert
Expert
Jump to solution

nice. Thanks Luc

0 Kudos