One of the daily checks I perform on our Windows Servers is to ensure they aren’t running low on disk space. There are a few ways this could be done, I could log on to each server individually …. but that would take longer than a full work day to complete. I could use SCOM or a 3rd party monitoring solution but that would cost money and I much prefer to not spend money.
The answer then?
PowerShell can audit all our servers in a few minutes and it can be automated so it will happen everyday without needing any involvement from me or any other sys admin.
By doing the check using PowerShell and with a scheduled task what could take all day takes me no time at all. All I need to do is open my inbox each morning and view the results.
The script I use is below, here are a few important things to note about it:
- You need to modify the email variables to be relevant to your environment.
- You will be prompted for credentials that have access to the servers that will be audited.
- It queries Active Directory to get a list of Windows Servers.
- The cmdlet Invoke-Command is used so that the workload is done on the remote server not your admin machine.
- The script looks for drives C,D,E,F and G. If you have other drives you will need to modify the script.
- It Looks for drives with less than 60GB remaining.
- The report is saved to your C:\Temp\ directory before being attached to an email and sent to you.
You can copy the script above or stay up to date with any updates on my GitHub page.