Export virtual machine name, folder, datastore and notes

From roonics
Revision as of 06:53, 1 August 2019 by Jlambert (talk | contribs)
Jump to navigation Jump to search

This script will give you the virtual machine name, folder, datastore and notes as below:

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