Alerting on disk space usage
In this example, we will do something a little bit different from the first two snippets. Here, we are going to report on disk usage. The basic snippet that gets this information is as follows:
Get-WmiObject -Class Win32_LogicalDisk -ComputerName $servername
If you want to report on only physical drives, you can add the following filter:
Where-Object DriveType -eq 3
In the e-mail we send out, however, we will add a little bit more formatting. We can do this by providing an inline CSS in the table we are constructing. In addition to general formatting, we are also creating a CSS class that we will assign to a row when that row's free disk space falls below a critical threshold that we assign.
The script is provided here. The script is a little bit long because of the HyperText Markup Language (HTML) and Cascading Style Sheet (CSS) construction. But some inline comments have been provided to explain the code:
#current server name $servername = "ROGUE" #if free...