Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 218415

Re: Datastore report with VI servers

$
0
0

Hi Arvin,

 

The following will work for you (I didn't realize that you weren't using Clusters).

Login to the Host from PowerCLI and run the following

 

# set the Target Folder where results will be output

# This checks to see if C:\Temp directory exists, if it does not, it is created and the results are stored in this directory
$targetFolder = "c:\Temp"
if (!(Test-Path -Path $targetFolder)) {
    New-Item -ItemType Directory -Path $targetFolder
}
Set-Location -Path $targetFolder

$outputfile = "./SMTPReport-" + (Get-Date -Format yyyy-MMM-dd-HHmm) + ".csv"

 

$report=@()
 

foreach ($v in (Get-VM)) {
   $ReportProp=[ordered]@{
   'VMname'=$v.name;
   }


  $ds_count = 1
  $ds = $v | Get-Datastore | foreach {
  $ReportProp.Add("DataStore$($ds_count) Name",$_.Name)
  $ReportProp.Add("DataStore$($ds_count) VMFS Version",$_.FileSystemVersion.split(".")[0])
  $ReportProp.Add("DataStore$($ds_count) Capacity GB",[math]::round($_.CapacityGB,2))
  $ReportProp.Add("DataStore$($ds_count) Free Space GB",[math]::round($_.FreeSpaceGB,2))
  $ds_count++
  }

   $report += New-Object -TypeName psobject -Property $ReportProp

}  

$report |
  Sort-Object -Property {($_ | Get-Member -MemberType NoteProperty).Count } -Descending |
  Export-Csv $outputfile -NoTypeInformation -UseCulture

Invoke-Item $outputfile


Viewing all articles
Browse latest Browse all 218415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>