Are You Automating Enough?
Earlier this week, Tony Redmond wrote about Jeffrey Snover – also known as the godfather of...
Update 02/13/2014: By popular demand, “Lost modified on:” field has been added which displays the date on which one of the settings on the virtual directory was last modified.
____________________________
Update 02/12/2014: Added some new features to the script. If you add -ADPropertiesOnly when calling the script, it will now only query the ADProperties which processes a whole lot faster in distributed environments. The script now also automatically creates a Remote PowerShell session if it cannot find an active one to use. It will connect to the server you specify with the -ComputerName parameter. If you choose not to specify the parameter, the script will create a remote PowerShell session to the localhost. Thirdly, there’s now also a -Filter parameter which allows you to filter the server(s) for which you want the see the results.
____________________________
The following command would query all CAS’es in the environment which have “02″ in their name and return the ADproperties for the different virtual directories:
Get-VirDirInfo -ReportPath c:\reports -ADPropertiesOnly -Filter *02*
Note: as you can see, I’ve also updated the -FilePath parameter to now be called -ReportPath. Some people reported that the previous name could be a little confusing. I would also like to thank Thomas Torggler for his input. He had some nice ideas!
The download link for the script can be found below.
____________________________
Update 01/30/2013: Based on feedback, I fixed the issue that script threw an error when there was only a single server.
____________________________
As a consultant, I regularly come across situations in which I have to troubleshoot an existing Exchange server environment or perhaps have to make an assessment, health report, etc.
Almost every time, I found myself looking up the information from the different (commonly used) virtual directories like: Autodiscover, ActiveSync, OWA, ECP, Web Services, OAB… That’s why I thought it became about time I automated this process so that I didn’t have to type the commands in manually anymore.
The result is a simple script which will query the Exchange Client Access Servers in your environment and will query them for their virtual directory information. Depending on the use of the virtual directory, different object are shown:
For now, (version 1.0), the script will only be able to show you information from Exchange 2010 and Exchange 2013. Also, it has to be run from an Exchange Management Shell.
In a future version, the script should also be able to provide results for Exchange 2007 and be ran remotely from a non-Exchange workstation or server.
The script will accept a single parameter to provide the path where the HTML-file should be located. For instance:
1
|
Get-VirDirInfo –FilePath c:\reports |
As usual, the script contains a function which you can re-use easily by dot-sourcing the script like this:
1
|
. .\ get-virdirinfo .ps1 |
There’s no real magic behind the code. First, we look for possible Exchange 2010 & 2013 Client Access Servers:
1
|
. $servers = Get-ExchangeServer | ?{ $_ .ServerRole -like "*ClientAccess*" -and (( $_ .AdminDisplayVersion -like "*15*" ) -or ( $_ .AdminDisplayVersion -like "*14*" ))} | Select-Object Name |
After that, we loop through the results and query for each virtual directory separately:
1
2
3
4
5
6
7
8
9
|
$autodvirdirresult = Get-AutodiscoverVirtualDirectory -Server $server .name | Select InternalUrl,ExternalUrl,InternalAuthenticationMethods,ExternalAuthenticationMethods $owaresult = Get-OWAVirtualDirectory -server $server .name | Select Name,Server,InternalUrl,ExternalUrl $ecpresult = Get-ECPVirtualDirectory -server $server .name | Select Name,Server,InternalUrl,ExternalUrl $oaresult = Get-OutlookAnywhere -server $server .name | Select Name,Server,InternalHostname,ExternalHostname,ExternalClientAuthenticationMethod, InternalClientAuthenticationMethod,IISAuthenticationMethods $oabresult = Get-OABVirtualDirectory -server $server .name | Select Server,InternalUrl,ExternalUrl,ExternalAuthenticationMethods, InternalAuthenticationMethods,OfflineAddressBooks $easresult = Get-ActiveSyncVirtualDirectory -server $server .name | Select Server,InternalUrl,ExternalUrl,ExternalAuthenticationMethods, InternalAuthenticationMethods |
The gathered is then stored in a separate table and written to an html-file:
1
|
$html | Out-File $filepath "\virdirinfo.html" |
Disclaimer: these scripts are provided “as-is” and are to be used on your own responsibility. I do not accept any liability nor do I take any responsibility for using these scripts in your environment. Please use with caution and always test them before usage! Enjoy!
Michael Van Horenbeeck is a Microsoft Certified Solutions Master (MCSM) and Exchange Server MVP from Belgium, with a strong focus on Microsoft Exchange, Office 365, Active Directory, and a bit of Lync. Michael has been active in the industry for about 12 years and developed a love for Exchange back in 2000. He is a frequent blogger and a member of the Belgian Unified Communications User Group Pro-Exchange. Besides writing about technology, Michael is a regular contributor to The UC Architects podcast and speaker at various conferences around the world.
Earlier this week, Tony Redmond wrote about Jeffrey Snover – also known as the godfather of...
When designing for a migration to Exchange Server 2013, chances are you’ll have to deal with public...