Wednesday, November 14, 2012

Drive Space Monitoring using PowerShell Script

In SharePoint servers monitoring disk space is a common administrator task. Because, SharePoint servers may run out of disk space from SharePoint, IIS Logs, SQL Server transaction logs or even from SharePoint content (If you don't have Quotas enabled!)

There are lot of first-party, third-party utilities available, such as SCOM to Monitor disk space. What if you don't have such tools in your environment? no worries, Just PowerShell can do the monitoring of disk
space! PowerShell disk space monitoring can be a cost saver too!

Schedule this PowerShell script in windows task scheduler("powershell.exe D:\scripts\DriveSpaceMonitor.ps1" . Make sure PowerShell is in your "Path" environment variable!) on hourly basis. Script will run every hour and mail only when the drive's free space goes below the provided threshold value.

Tail: SharePoint 2010's Health analyzer has the rule to check "Drives are running out of free space." which can be utilized as well. But by default SharePoint health analyzer won't send email notifications and only display to users within Central Administration.