PowerCLI one-liner to find the VM which has Raw access to a particular LUN

We had a requirement to find the VM with RDM which holds specific naa ID. The following one-liner made our task easy.

[crayon lang=”powershell”]
Get-VM | Get-HardDisk-DiskType”RawPhysical”,”RawVirtual” | where {$_.ScsiCanonicalName -eq “naa.60008ac00071254a”} |
Select-Object Parent, ScsiCanonicalName
[/crayon]