Code snippet – Report all VMs on a datastore

This script will report all VMs and the name of the datastore.

Just fill in the name of your vCenter Server in the first line:

Connect-VIServer vCenter-Server

foreach($ds in Get-Datastore){
     foreach($vm in ($ds | Get-VM)){
          $vm | Select @{N="VMname";E={$_.Name}},

Leave a Comment

Your email address will not be published. Required fields are marked *