Tag Archives: script

Powershell Script to Determine Active User Count for Microsoft Exchange 2010 and Exchange 2007

A script that I came up with to determine the user load that is being placed on a particular Exchange server so that you can plot the days of the week and times of the day that are busiest. This Powershell Script can be used with GFI Max Remote Management or SpiceWorks to easily identify busy Exchange servers.

$GETMSEXCHISAUC = Get-Counter ‘\MSExchangeIS\Active User Count’
$MSEXCHISAUC = $GETMSEXCHISAUC.CounterSamples |Select-Object CookedValue
Write-Host You have $MSEXCHISAUC.CookedValue Active Exchange User Connection\s to the Exchange Server

Feel free to edit the text part of the output (Last line), this could be simplified if required.

Powershell Script to Determine Number of Connections to your Microsoft Terminal Services Gateway

I’ve put together another script that might be useful for monitoring how busy your Terminal Services Gateway is at various times of the day.  This Powershell Script can be used with GFI Max Remote Management or SpiceWorks to easily identify busy servers.

$GETTSGWCC = Get-Counter ‘\Terminal Service Gateway\Current connections’
$TSGWCC = $GETTSGWCC.CounterSamples |Select-Object CookedValue
Write-Host You have $TSGWCC.CookedValue Current Connection\s to the Terminal Services Gateway

Feel free to edit the text part of the output (Last line), this could be reduced/simplified if required.

Microsoft Exchange 2007 and 2010 – Messages Queued For Delivery Powershell Script

I’ve been getting into Powershell in a big way the past few months and have put together a script to display the number of queued messages on a Microsoft Exchange 2007 or Microsoft Exchange 2010 Server.  Under normal conditions your mail queue should really be empty most of the time so lots of queued messages is indicative of a problem.

 

$GETMQFD = Get-Counter ‘\MSExchangeTransport Queues(*)\Messages Queued For Delivery’

$MQFD = $GETMQFD.CounterSamples |Select-Object CookedValue

If ($MQFD.CookedValue | Where {$_ -eq 0})

{

Write-Host $MQFD.CookedValue Messages Queued for Delivery

}

Else

{

Write-Host “No Messages Queued For Delivery”

}

 

If you are using a Server Monitoring package such as GFI Max Remote Management then you can insert Exit Codes (i.e. Exit 1 or Exit 0).  This is placed after the output (i.e. Write-Host “No Messages Queued For Delivery”) to generate an onscreen error or success if one of the two conditions is met.