Export virtual machine name, folder, datastore and notes

From roonics
Revision as of 09:04, 20 March 2022 by Jlambert (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 />