Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Free Space with Warning

Status
Not open for further replies.

ProliantFan

Technical User
Feb 16, 2004
26
EU
Hi guys,

As a real scripting Noob i can figure out how to get what i want with this script

Get-WMIObject Win32_LogicalDisk -filter “DriveType=3" -computer (Get-Content "\\server\Share\scripts\servers.txt") | Select SystemName,DeviceID,VolumeName,@{Name=”size(GB)”;Expression={“{0:N1}” -f($_.size/1gb)}},@{Name=”freespace(GB)”;Expression={“{0:N1}” -f($_.freespace/1gb)}},@{Name=”ProcentFree”;Expression={“{0:N1}” -f($_.freespace/$_.size * 100)}} | Out-GridView

This script gives me a nice view of all disk for all servers with the percentage of free diskspace.

But what would like to add is if the %free is less than 10% that a warning is given in an extra colom. Anyone have any idea's ?
 
The Expression can be lots of things. You could add another calculated property after your PercentFree column like this:
Code:
@{Name="Warning";Expression={If($_.freespace/$_.size -lt 0.1) {"Danger"}}}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top