/PowerCLI: VMware List VM’s per Datastore vs CanonicalName.

PowerCLI: VMware List VM’s per Datastore vs CanonicalName.

This week I need to create a script to list all VMs. This particular script display all VMs that are inside in some particularly iSCSI LUNs. Since VMware environment could have iSCSI, NFS and also Local Disks, so we need to search by CanonicalName. In this case iSCSI LUN CanonicalName.

Some examples of CanonicalName that we can search with Get-ScsiLun:

mpx.vmhba1:C0:T0:L0 – Local Storage
naa.600508b1001cd496d9b6de3cd17** – Local Disks
eui.0824c2ed87fe91f6 or eui.7d374ff1ab9a3558 – iSCSU LUNs

Note: If you want to exclude the Local Disks and/or Local Storage from the search, just add  -and $_.IsLocal -like “False”  in the Get-ScsiLun.

So by searching the CanonicalName, we can search and List all VMs inside. We can use CanonicalName for iSCSI, Local Disks, and Local Storage(system). In this case, we are only using for iSCSI LUNs.

This is the script:

The initial part of this script (the New-VIProperty parameter) was based on a script that we found in www.vsysad.com.

Note: Again many thanks to my colleague Vladimir Sokol for is scripting qualities for the help, improvement and also taking the script to a higher next level.

Hope this script can help and be useful.

Note: Share this article, if you think is worth sharing.

©2017 ProVirtualzone. All Rights Reserved
By | 2018-03-12T01:46:58+01:00 February 26th, 2017|VMware Posts|0 Comments

About the Author:

I am over 20 years’ experience in the IT industry. Working with Virtualization for more than 10 years (mainly VMware). I am an MCP, VCP6.5-DCV, VMware vSAN Specialist, Veeam Vanguard 2018/2019, vExpert vSAN 2018/2019 and vExpert for the last 4 years. Specialties are Virtualization, Storage, and Virtual Backups. I am working for Elits a Swedish consulting company and allocated to a Swedish multinational networking and telecommunications company as a Teach Lead and acting as a Senior ICT Infrastructure Engineer. I am a blogger and owner of the blog ProVirtualzone.com

Leave A Comment