Retrieve list of VMs by filtering datastore location

As part of a SAN maintenance task that was being performed I wanted to obtain the virtual machines where the hard disks were hosted on those affected datastores, this was a non-disruptive task so there was no requirement to perform Storage vMotion.

Again, the method to retrieve this information was vSphere PowerCLI and no longer than 30 seconds to compile and invoke. The naming convention of the datastores allows for the SAN to be distinguished therefore by retrieving a list of virtual machines and filtering by datastore using a wildcard this was easily achieved:

In my example, I am using the below datastore name naming convention where the affected SAN would be named SAN1 (obviously in the real world by naming conventions are far more imaginative!) :


Get-VM -Datastore SAN1* | fl Name

This would ensure that only VMs where hard disks on the below datastores would be returned:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s