Backtrack:  
 
by lunarg on December 12th 2017, at 12:35

When performing large storage migrations, it may be useful to get a list of VMs and the datastore and/or folder they are located in. PowerCLI can provide this very quickly:

Get-VM | Select Name,@{N="Datastore";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},@{N="Folder";E={$_.Folder.Name}}

You can further pipe this to other cmdlets (such as Where-Object to filter even more), or export it to a CSV.

You can also go into more detail and determine the location of each virtual disk (VMDK) of each VM:

Get-VM | Get-View | % {
    $name = $_.Name
    $_.Layout.Disk | % {
        New-Object PSObject -Property @{
            Name = $name
            Disk = $_.DiskFile[0]
        }
    }
}

As always you can adjust the snippet above further.

 
 
« December 2018»
SunMonTueWedThuFriSat
      1
2345678
9101112131415
16171819202122
23242526272829
3031     
 
Links
 
Quote
« You only find out who is swimming naked when the tide goes out. »
Warren Buffett