I have a number of sites still running Exchange 2010 and because of the buggy management pack there is often not a way to alert on the drive space of an exchange server mount point because sites have removed the management pack.
In searching for a solution, I came across a nice article that helped get me started here:
http://www.powershellneedfulthings.com/?p=36
I took that script and added some additional information so that I could generate both an error condition on low drive space as well as a recovery alert so SCOM knew when to close the alert itself.
In order for this script to run cleanly, you first need to run the following powershell command on any server you want to run mout-point checks on:
new-eventlog
-LogName System -Source OpsHealthScript
Next, schedule the following script to run periodically on your server via task scheduler or whatever program you might use to run scripts on a recurring basis.
$TotalGB = @{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/ 1073741824),2)}}
$FreeGB = @{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace / 1073741824),2)}}
$FreePerc = @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0)}}
$Check = @{Name="Failed";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0) -lt 10}}
function get-mountpoints {
$global:volumes = Get-WmiObject -computer $server win32_volume | Where-object {$_.DriveLetter -eq $null}
$global:volumes | Select SystemName, Label, Capacity, FreeSpace, $Check | Format-Table -AutoSize
}
$servers = [system.environment]::MachineName
foreach ($server in $servers){
get-mountpoints
}
$Flag = $global:volumes | Select $Check
If ($Flag -match "True") {
Write-EventLog -logname System -source OpsHealthScript -eventID 500 -Entrytype Error -message 'One or more Exchange mount points are below 10% free space.'
}
Else {
Write-EventLog -logname System -source OpsHealthScript -eventID 800 -Entrytype Information -message 'Exchange mount points are healthy.'
}
You can access the file here: mount-point-space.ps1
Once this is scheduled, you can setup alerting in a couple of ways, one is a simple alert detection within SCOM to detect Error 500 in the system event log, the other is a correlated alert detection so that each alert generated by the script does not create a new alert within SCOM. I'll go over that in additional detail.
Search This Blog
Showing posts with label Exchange 2010. Show all posts
Showing posts with label Exchange 2010. Show all posts
Thursday, July 30, 2015
Friday, March 27, 2015
Exchange Inventory Powershell Script
Not SCOM related, but I cobbled together a powershell script that gives useful information for your exchange inventory. In particular, I was looking to re-balance my exchange databases and wanted to get the particulars of all my user mailboxes. I find that using using the alias when running some of the move commands is easier. The script will provide you with the following information:
$(Foreach ($mailbox in Get-recipient -ResultSize Unlimited -RecipientType UserMailbox){
$Stat = $mailbox | Get-MailboxStatistics | Select TotalItemSize,ItemCount
New-Object PSObject -Property @{
DisplayName = $mailbox.DisplayName
TotalItemSize = $Stat.TotalItemSize
PrimarySmtpAddress = $mailbox.PrimarySmtpAddress
Alias = $mailbox.Alias
Database = $mailbox.Database}
}) | Select DisplayName,TotalItemSize,PrimarySmtpAddress,Alias,Database
- Users's display name
- Total size of the user's mailbox
- The primary SMTP address for the user
- The user's alias
- The database on which the mailbox is located
$(Foreach ($mailbox in Get-recipient -ResultSize Unlimited -RecipientType UserMailbox){
$Stat = $mailbox | Get-MailboxStatistics | Select TotalItemSize,ItemCount
New-Object PSObject -Property @{
DisplayName = $mailbox.DisplayName
TotalItemSize = $Stat.TotalItemSize
PrimarySmtpAddress = $mailbox.PrimarySmtpAddress
Alias = $mailbox.Alias
Database = $mailbox.Database}
}) | Select DisplayName,TotalItemSize,PrimarySmtpAddress,Alias,Database
Subscribe to:
Posts (Atom)