I need to show disks space free less than 99%.

# 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

}

Please share some more information about the specific problem you are experiencing, and what you have already done to try to resolve it.

You should look specifically here:

((($_.freespace/1gb)/($_.size/1gb)) -le '0.99')

‘0.99’ is a string and is not converted to a number, so -le won’t work. Take a look at this post:

https://powershell.org/forums/topic/outputs-not-working-as-expected/

solved

I change code ((($.freespace/1gb)/($.size/1gb)) -le ‘0.99’)

now ((($.freespace/1gb)/($.size/1gb)) -le 0.99)