Link to home
Start Free TrialLog in
Avatar of cwstad2
cwstad2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

powershell where condition

Hi guys, i have the following code which worked until i tried to use the where condition. Im looking for only values less than 5 to be part of the output. i think im almost there. Any advice would be great

thanks

$Servers = Get-Content  C:\Users\Downloads\exchange.txt


foreach ( $Server1 in $Servers ) {
@"
$server1
"@

$disk = Get-WmiObject Win32_LogicalDisk -ComputerName $Server1 -Filter "DeviceID='C:'" |
  Where-Object {$_.FreeSpace -lt "5"}

$disk.FreeSpace /1GB -as [int]
 }
SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cwstad2

ASKER

Damn would you believe it. Thanks. Is there a way to supress the results with the ones greater than 5GB. Its showing the results for all.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cwstad2

ASKER

Much better formatting thank you very much