Export virtual machine name, folder, datastore and notes

From roonics
Jump to navigation Jump to search

This script will give you the virtual machine name, folder, datastore and notes as below and dump it to myreport.csv in c:\temp:

Get-VM |
Select Name,
@{N="Datastore";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},
@{N="Folder";E={$_.Folder.Name}},
@{N='Notes';E={$_.Notes.Replace("`n",'/')}} | export-csv c:\temp\myreport.csv

Example output:


Name            Datastore                           Folder                     Notes
----            ---------                           ------                     -----
Server01        iscsi_datastore01                   Domain controllers         Domain controler
Server02        fc_datastore01                      Misc servers               FTP Server
Server03        fc_datastore01                      UK servers                 Doc share

‎<comments />