Monday, October 27, 2014

How To: Scripts for AutoDiscover, EWS, IIS, OAB and RCA Stats #MSExchange

Introduction:

Nothing makes the life of an Exchange administrator easier than good PowerShell scripts! Recently, one of my MCM colleagues Ingo Gegenwarth shared several scripts with me that are fantastic! Ingo’s motivation to write the scripts came from the need to help gather statistics for the day-to-day troubleshooting scenarios of bad ActiveSync, AutoDiscover, AutoDiscover MobileSync, EWS, OAB and Outlook Anywhere responses.

There are seven scripts that I have shared in the reference section of this post. I’ll go through three of the scripts that actually helped me this past weekend.

Get-AutoD.ps1

This script when executed will provide the AutoDiscover response for an email address that you provide. If you are troubleshooting a particular server you can also use the –Server switch and specify the specific server name.

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass


I like using this command because it sets the execution policy to bypass for the existing PowerShell session. This option will allow a script, which is not digitally signed to be executed within the PowerShell window. Many people set the execution policy to unrestricted, which is a global change and a downgrade in security.


Next, we need to provide a set of credentials.

$cred = Get-Credentials jharris@contoso.local

Now, we run the script to search for the Autodiscover response for the jharris mailbox.


.\Get-AutoD.ps1 –EmailAddress jharris@contoso.local -Credentials $cred

If we wanted to focus on a specific server we could also use the following syntax.

.\Get-AutoD.ps1 –EmailAddress jharris@contoso.local -Credentials $cred –Server ex01.contoso.local




Get-AutoDMobile.ps1

This script will query AutoDiscover and provide the Mobilesync response for a specific email address.

First, we need to provide a set of credentials.

$cred = Get-Credentials jharris@contoso.local

Next, we run the script to look for the Mobilesync response for jharris@contoso.local.


.\Get-AutoMobile.ps1 –EmailAddress jharris@contoso.local -Credentials $cred


Get-IISStats.ps1


This script will look through the Exchange IIS log files to report on a user based on a time range and/or AD-site. The script expects that the server that is running the script has LogParser installed in the default location. The script will then enumerate all Exchange servers found within the current AD-site unless the AD-site switch is used.

To run the script and look for user justin.harris, we issue the following command.

.\Get-IISStats.ps1 –UserID justin.harris  -Outpath c:\temp\output



The script will then export any matches to c:\temp\output. Using Microsoft Excel, I am able to find matches for justin.harris connecting with an iPhone and iPad.



Conclusion:


The foundation of a healthy administrator’s life starts with finding ways to work smart so valuable hours in the workweek can be saved. Thankfully, Ingo and thousands of others who contribute to the Microsoft Script Center help administrators like me find more time in the workweek.

Now where is my TitanFall disc…


References:







No comments:

Post a Comment