Hi All
I am hoping to get some assistance as this script has been doing my head in.
Taken snippets from multiple sources.
Objective: Report back on servers where percentfree space is less than 10%. This is for drives such as CSV drives where the drive letter is not assisgned. I can get the report to give me the output however it is giving me the drives even above the threshold
$TotalGB = @{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/ 1073741824),2)}}
$FreeGB = @{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace / 1073741824),2)}}
$FreePerc = @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0)}}
#grab the names of the servers/computers to check from the list.txt file.
$computers = get-content "C:\temp\servers.txt"
# Set free disk space threshold below in percent (default at 10%)
[decimal]$thresholdspace = 10
#assemble together all of the free disk space data from the list of servers and only include it if the percentage free is below the threshold we set above.
$tableFragment= Get-WMIObject -Computer $computers Win32_Volume |
Where-Object {$_.DriveLetter -eq $null -AND $_.label -ne "System Reserved" -AND $_.FreePerc -lt [decimal]$thresholdspace} | select __SERVER, Label, $TotalGB, $FreeGB, $FreePerc
$tableFragment
Would really appreciate any assistance