Created
September 13, 2016 10:32
-
-
Save anonymous/b0d3cfda7b3f15ad5f62d77e3ba8907c to your computer and use it in GitHub Desktop.
Quick and Dirty HTML report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$body = "<table> | |
</col></col> | |
<th>Drive</th><th>Freespace</th>" | |
$drives = Get-WmiObject -Class win32_logicaldisk | |
foreach ($drive in $drives){ | |
$props = @{'ID'=$drive.DeviceID; | |
'freespace'=$drive.freespace /1gb} | |
$obj = New-Object -TypeName psobject -Property $props | |
if($obj.freespace -lt 100){ | |
$body += "<tr bgcolor='Red'> | |
<td><p>$($obj.ID)</td> | |
<td>$($obj.freespace)</td> | |
</tr>" | |
} | |
else{ | |
$body += "<tr bgcolor='green'> | |
<td>$($obj.ID)</td> | |
<td>$($obj.freespace)</td> | |
</tr>" | |
} | |
} | |
$body += "</table>" | |
ConvertTo-Html -Body $body | Out-File .\test.html | |
Invoke-Expression .\test.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment