locked
I need to show disks space free less than 99% RRS feed

  • Question

  • # Get SQL Server hostname
    $hostname=Get-WMIObject Win32_ComputerSystem | Select-Object -ExpandProperty name
    
    # Get all drives with free space less than a threshold. Exclude System Volumes
    $Results = Get-WMIObject -ComputerName $hostname Win32_LogicalDisk |
    where{($_.DriveType -eq 3) -and ((($_.freespace/1gb)/($_.size/1gb)) -le 0.99)}
    
    ForEach ($Result In $Results)  # $Results variable does not contain values
    {
    $drive = $Result.DriveLetter # I can not set this variable
    $space = $Result.FreeSpace # I can not set this variable
    
    }

    Thursday, February 20, 2020 11:45 AM

All replies

  • Don't you like the answers you've got there

    https://powershell.org/forums/topic/i-need-to-show-disks-space-free-less-than-99/

    When you crosspost the same question to different forums at the same time you should post links to the other posts in the other forums along with your question to avoid people willing to help you doing their work twice or even more.

    Thanks.


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    • Edited by BOfH-666 Thursday, February 20, 2020 12:06 PM
    Thursday, February 20, 2020 12:04 PM