Hello,
I need to edit this script so that it will also return the Cluster name and if possible the VC name as well as the DS name. Can anyone suggest what needs to be added to get these to show up on the report? Don't need to know VM or VMDK names.
$vCenterList = "VC1","VC2"
$cred = get-Credential
Function Percentcal {
param(
[parameter(Mandatory = $true)]
[int]$InputNum1,
[parameter(Mandatory = $true)]
[int]$InputNum2)
$InputNum1 / $InputNum2*100
}
foreach ($vcenter in $vCenterList)
{
Connect-VIServer -server $vcenter -credential $cred
$datastores = Get-Datastore | Sort Name
ForEach ($ds in $datastores)
{
if (($ds.Name -match “Shared”) -or ($ds.Name -match “”))
{
$PercentFree = Percentcal $ds.FreeSpaceMB $ds.CapacityMB
$PercentFree = “{0:N2}” -f $PercentFree
$ds | Add-Member -type NoteProperty -name PercentFree -value $PercentFree
}
}
}
$datastores | Select Name,@{N=”UsedSpaceGB”;E={[Math]::Round(($_.ExtensionData.Summary.Capacity – $_.ExtensionData.Summary.FreeSpace)/1GB,0)}},
@{N=”TotalSpaceGB”;E={[Math]::Round(($_.ExtensionData.Summary.Capacity)/1GB,0)}},
@{N=”FreeSpaceGB”;E={[Math]::Round(($_.ExtensionData.Summary.FreeSpace)/1GB,0)}}, PercentFree | Export-Csv C:\Temp\Report.csv -NoTypeInformation