Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Add a column in this script to put an '*' if the PercentFree is below 10%

$
0
0

I want to add a column to the output called ATTENTION.  In that column I want to display an "*" if percentfree is < 10%

Any suggestions?

$servers = get-content servers.txt
foreach ($server in $servers)

{
$Size = @{name="Size(GB)";expression={ "{0:N2}" -f ([double]$_.Size/1GB) }}
$FreeSpace = @{name="FreeSpace(GB)";expression={ "{0:N2}" -f ([double]$_.FreeSpace/1GB) }}
$Used=@{name="Used(GB)";expression={ "{0:N2}" -f (([double]$_.Size-[double]$_.FreeSpace)/1GB) }}
$PercentFree=@{name="PercentFree";expression={ "{0:P2}" -f ([double]$_.FreeSpace/[double]$_.Size) }}
$PercentUsed=@{name="PercentUsed";expression={ "{0:P2}" -f (([double]$_.Size-[double]$_.FreeSpace)/[double]$_.Size) }}

Get-WmiObject Win32_LogicalDisk -filter "DriveType=3" -computerName $server| Select-Object SystemName,DeviceID,VolumeName,$Size,$FreeSpace,$used,$PercentFree,$PercentUsed |ft -Property * -autosize | out-string -Width 4096  > "$server.txt"
$server
}


http://techwithmike.com


Viewing all articles
Browse latest Browse all 21975

Trending Articles