lorried82
Enthusiast
Enthusiast

Hi LucD - so if I wanted to take this script and have the output just provide me with the name - how can I do that? When I strip down the report I am getting an Attempted to divide by zero error....I want the report to only provide output for Used% > 90 AND if provisionedspaceGB > totalspaceGB. I want to still have the option to add datastores I don't want checked as well.

 

#powershell script to query the datastores for Used% > 90% AND provisionedpsace > totalspace

connect-viserver '<server>' -User '<user>' -Password '<password>'

$undesiredDatastores = @('local*')

$TotalSpaceGB=[math]::Round($_.CapacityGB,0)

$UsedSpaceGB=[math]::Round($_.CapacityGB - $_.FreeSpaceGB,0)

$UsedSpace%=[math]::Round(($_.CapacityGB - $_.FreeSpaceGB)/$_.CapacityGB*100,0)

$ProvisionedSpaceGB=[Math]::Round(($_.CapacityGB - $_.FreeSpaceGB + $_.ExtensionData.Summary.Uncommitted/1GB),0)

$AmountOverprovisionedGB=[Math]::Round($_.ExtensionData.Summary.Uncommitted/1GB – $_.FreeSpaceGB,0)

$report=Get-Datastore |

where{$undesiredDatastores -notcontains $_.Name} | Select Name | Where{$_.'UsedSpace%' -ge 90 and $_.'ProvisionedSpaceGB' -gt $_.'TotalSpaceGB'} |

Sort-Object -Property Name

Reply
0 Kudos