Skip to content

Instantly share code, notes, and snippets.

Created September 13, 2016 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b0d3cfda7b3f15ad5f62d77e3ba8907c to your computer and use it in GitHub Desktop.
Save anonymous/b0d3cfda7b3f15ad5f62d77e3ba8907c to your computer and use it in GitHub Desktop.
Quick and Dirty HTML report
$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