A lot of the magic VMware provides relies on shared storage. If a VM is on local storage, you can’t VMotion it, HA won’t restart it, and a host of other limitations. Do you know which of your VMs, if any, are on local storage? This script can make answering that question pretty easy. First, here’s a function that will locate datastores that use shared storage.
To use, launch PowerCLI, connect to your vCenter server, load the function above and run:
1 |
Get-ShareableDatastore |
And you’ll wind up with a list of datastores that your hosts can share.
But that’s not what we’re after, we want datastores that can’t be shared. Not too hard,
1 |
$sharableIds = Get-ShareableDatastore | Foreach { $_.ID } |
1 |
$localOnly = Get-Datastore | Where { $sharableIds -notcontains $_.ID } |
Once we have $localOnly, we pass that to Get-VM.
1 |
$localOnly | Get-VM |
This gives us the list of VMs that can’t be shared amongst hosts.