Thursday, October 10, 2013

Powershell Script - Remote Drivespace (Mountpoints) Emailed Report

10/09/2013: Today's post will outline a remote drivespace reporting script that I routinely use to monitor and report on the available Transaction Log space on my Exchange servers. The script leverages WMI to remotely query for the current freespace & volume size metrics (on either specified drive letters, or all Volume Mount Points on the target system), calculates the space in terms of gigabytes and percentage-free, outputs a report file, and emails the results to an admin mailbox.

I'd generally design this type of script to leverage Exchange Management Shell and dynamically query all servers in the appropriate site in the mailbox role (to automatically accommodate server adds and removals over time). But in this case I wanted this script to be 'blind' to Exchange version differences and also avoid a dependency on Exchange Management Shell. A specific goal in this case was to provide a tool to enable junior admins to evaluate the drive status after backup failure alerts, without the need to run the queries from a machine with a specific version of the Exchange Management Tools installed. So I instead use semicolon-delmited string variables to statically store arrays of server names for processing within the script itself.

Wednesday, October 9, 2013

Powershell Script - Hub Queue Live Monitoring Script (Exch2007/Exch2010)

10/09/2013: Here's a script I've used in various forms since around 2007: A basic rolling Exchange Hubtransport Queue Depth monitor.

I've found over time, that regardless of SCOM or other active monitoring in place for your Exchange infrastructure, you can often see problems show up early and first in queuing behavior on your HubTransport servers:
  • Experiencing mail server storage latency issues? You'll probably see increasing patterns of queuing in the MapiDelivery queues to the problem stores, as you move into peak business primetime hours and increasing mail load delivers into the hubs, but can't be delivered into the mailbox server transaction logs and stores, fast enough to keep pace with the mail flow.
  • Experiencing cpu-saturation, or other capacity issues on your hubs, or Hub-CAS hybrid systems? You'll probably see the footprint on the CPU-dependant AV-scanning processes (you ARE running antivirus scanning on your hubs, correct? :D), which will lead to mail queuing in the Submissions queues.
    --in my case, I most recently saw this as a product of CAS Exchange Web Services load -- from Lync -- soaking up more CPU than the systems had been provisioned for, in 2007, well before the Lync infrastructure had been tacked onto the Exchange infrastructure -- looong story behind that one, that predated my arrival at the firm. :P))

So in a nutshell, I've found it a pretty good backup-monitoring option, to run a self-refreshing console display on the current queue status of all hubs in a given Exchange revision.

Wednesday, October 2, 2013

Powershell Script - Using EMS Get-MessageTrackingLog + LogParser to Retrieve Top-Traffic Metrics for the Hubs in a Site

10/02/2013:All mail admins will occasionally see "odd" Exchange HubTransport queuing behavior for "unknown" reasons (I'll generally notice these type of events in response to monitoring alerts or via a looping get-queue monitoring script I run 24/7).

In most cases these little 'surges' come and go in a matter of minutes with no material impact or footprint. But on other occasions, you see something about the queuing that warrants further investigation into exactly what occurred:
  • Possibly your interest is piqued due to the amount of mail that queued up (say a sudden spike into hundreds if not thousands of messages in normal delivery queues)
  • Or possibly you want to check further due to mail rapidly piling up in queues where you traditionally should see little to no traffic (e.g. in the Unreachable queue).

Powershell Snippet - Copy/Distribute a File to Every Exchange Server, With Preference Order as to Which Target Drive

10/02/2013: Here's another handy Powershell script snippet: This time, a chunk of code I use for quickly distributing a new or updated file to all or a subset of Exchange servers using Powershell+Exchange Management Shell

Pretty simple process going on below:
  1. I store a list of drive letters to be tested into an array (in preference order)
  2. Then utilize the EMS get-exchangeserver cmdlet to collect a filtered set of all exchange servers (in this case, using
    get-exchangeserver | where{$_.isHubTransportServer -eq $true} to return only HubTransports anywhere in the Org)
  3. I then loop the exchange servers list against the drives array, testing for a functional path (which indicates a suitable target drive), and using the {break} command to drop out of the loop at the first matching drive in the list. 
  4. Whereuopon the designated file is copied to the matching UNC path

Copy/Distribute file to every exchange server, with preference order  as to which target drive: (1-line below; the command skips tests and copies to the first match)