Hi all,
I'm totally new to PowerCLI but need to identity the simplest and shortest way for me to list all the virtual machines in my vCenter server that currently have a CDdrive attached.
I though I'd be able to achieve this with get-vm | get-CDDrive but no results are shown.
I've seen plenty of examples on the web of how people want to disconnect all drives in one hit, but initially I only want to identify them for a report.
Can this be achieved in a one liner?
Thanks
Try something like this
Get-VM | where {$_.cddrives} | Select Name, @{N="Connected";E={(get-CDDrive -VM $_).ConnectionState}}
or if you only want to see the ones that are connected, you could do this
Get-VM | where {$_.cddrives} | Select Name, @{N="Connected";E={(get-CDDrive -VM $_).ConnectionState.Connected}} | where {$_.Connected}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes
Get-VM | where {$_.CDDrives} | Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is close to what I want.
At least it lists all of my virtual machines which actually contain a CDROM but it doesn't identify which have the CDROM in a connected state.
Try something like this
Get-VM | where {$_.cddrives} | Select Name, @{N="Connected";E={(get-CDDrive -VM $_).ConnectionState}}
or if you only want to see the ones that are connected, you could do this
Get-VM | where {$_.cddrives} | Select Name, @{N="Connected";E={(get-CDDrive -VM $_).ConnectionState.Connected}} | where {$_.Connected}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference