GWI Win32_Volume threshold not working

Welcome Forums General PowerShell Q&A GWI Win32_Volume threshold not working

This topic contains 1 reply, has 1 voice, and was last updated by

4 years, 6 months ago.

  • Author
  • #18611

    Points: 0
    Rank: Member

    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

    Would really appreciate any assistance

  • #18612

    Points: 0
    Rank: Member

    And right after I post this I figured it out. Probably not the cleanest

    Where-Object {$_.DriveLetter -eq $null -AND $_.label -ne "System Reserved" -AND (((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0) -lt $thresholdspace}  | select __SERVER, Label, $TotalGB, $FreeGB, $FreePerc

The topic ‘GWI Win32_Volume threshold not working’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort