Update 12/09/2016: script updated to version 1.8:

  • Included support for Exchange 2016 CU2+
  • Made some minor changes to the code + output now shows a message if successful/unable to write the html file.

Previous updates in version 1.7:

  • Added more recent Exchange build numbers
  • Updated download location to TechNet Script Gallery

You can download v1.8 here


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

The script will accept a single parameter to provide the path where the HTML-file should be located. For instance:

[sourcecode language=”powershell”]Get-VirDirInfo –FilePath c:\reports[/sourcecode]

As usual, the script contains a function which you can re-use easily by dot-sourcing the script like this:

[sourcecode language=”powershell”]. .\get-virdirinfo.ps1[/sourcecode]


You can download v1.8 here

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!


  1. Hi, I have downloaded your script (Thanks :)) but when i run it just returns me a prompt and nothing else.

    This is what i am running
    .\get-virdirinfo.ps1 -filepath d:\reports

    It prompts me for:-
    Security Warning
    Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your
    computer. Do you want to run D:\Exchange_Scripts\get-virdirinfo.ps1?
    [D] Do not run [R] Run once [S] Suspend [?] Help (default is “D”):

    I select R and then I just get a the PS prompt.

    Any ideas? (This is on a 2010 CAS server)


    1. Hi,
      it’s because the script wasn’t made to be run like that. You have to modify it, or dot-source it first.

      The reason you have to dot-source it, is because the script is basically a function and I don’t “call” the function in the script self.

      Try dot-sourcing the script first and then running it using Get-VirDirInfo -FilePath , that should work.

      Alternatively, you could just add the following line at the bottom of the script:
      Get-VirDirInfo -FilePath and then just call the script running Get-VirDirInfo.ps1 (no parameters).

      Let me know if that worked.

      1. Hi,

        Thanks. dot-sourcing didn’t work unfortunalty just put me right back at a prompt. Adding your suggestion at the end of the script worked and i have the output file but PS console did generate errors:-

        Attempted to divide by zero.
        At D:\Exchange_Scripts\get-virdirinfo.ps1:204 char:113

        Though the output file seems to contain the relevant info.

      2. It’s odd to see the script fail at that point, because it’s only doing exactly the same things as higher up the script, only for ActiveSync at that time.
        Even more odd to see that it did create the output successfully.

        Nonetheless, glad you got it to work 🙂

      3. Thanks for the help :). I should have clarified that that error happens for all vds, just i copied one example :).

      4. Aha! Okay 🙂

        Try commenting out the following line(s) that start with:
        Write-Progress -Activity “Getting…

        It should help removing the error, but you won’t see a progress bar. I suspect something’s off with how I calculate the progress, based on the results from one of the earlier queries.

        Have just re-tested it in 2 different environments, but cannot reproduce the error though…:(

  2. Hello
    Thank’s to share your knowledge.

    I have a single exchange 2013 server with the 2 roles.
    (not working as expected It’s why google drive me here, and as the autodiscover internal and externalurl return empty in virdirinfo.html the problem should sit here)

    I get a Attempted to divide by zero.
    At C:\script\get-virdirinfo.ps1:73 char:13
    + Write-Progress -Activity “Getting Autodiscover URL information” -Sta …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException

    and all other write-progress

    As i have only one server the count property doesn’t exist.
    Solved with @ ()
    $servers = @(Get-ExchangeServer | ?{$_.ServerRole -like “*ClientAccess*” -and (($_.AdminDisplayVersion -like “*15*”) -or ($_.AdminDisplayVersion -like “*14*”))} | Select-Object Name )


      1. Right now, nothing. I am working on an updated version which should be ready any time soon… 🙂
        Just hang in there for a few more hours!



  3. Hello
    Late reply, but to much subjet to deal with (SBS2003 to Exchange 2013/AD 2012- Citrix Xenapp – Datacore melody to symphony migration – Cluster Fortinet to setup- Vmware migration …)
    When I setup the new domain and new exchange, the old one was in line, and public ip goes to sbs.
    In my mind in the local network the autodiscover .local was enought but I realized that the autodiscover is allways trying public autodiscover.
    So i add the public zone in the dns to match the local ip

    I have another problem: the outlook autoconfig is ok for domain logged on user, but with manual configuration it is not possible to check the adress mail. I get an error message: Unable to perform a Check Name or connect to an Exchange mailbox. And I could not create a outlook profile for a non domain pc.
    => the virtual directories have all the default authentification method created at setup, maybee it is the source of this problem? or a ssl problem?

    1. It does not necessarily us the external dns names. It all boils down to how you configured your URLs. What is the url for the AutodiscoverserviceInternalURl? How is it published?

      Did you try using the remote connectivity analyzer to validate your setup? If not, I suggest you do as that might provide some extra information for troubleshooting.

    1. Can you provide some more info on your topology? All 2010/2013 servers?
      Try running the Get-ExchangeServer cmdlet from the code manually and see what results come up.

      Let me know! 😃

  4. Hello, I have tried to RUN the script but with no luck. I have RUN the command after I copied the PowerShell script into my temp folder
    .\Get-VIrDirInfo.ps1 -FilePath c:\Temp

    NO LUCK Please can you assist?

    1. I realize this reply comes way too late, but I suspect that you haven’t properly dot-sourced the script before. Check my previous reply for some info on it.
      I WILL remove the need to dot source it in vNext though 😉

  5. Hi Michael, can you please let me know how to dot-source before using the script? I did ../get-virdirinfo.ps1 and complained that it is not recognized as the name of a cmdlet. I am not a programmer but I am an Exchange Administrator. Thank you very much.

    1. Hey Semon,

      to dot-source the script, just run the following:

      . .\scriptname.ps1

      So, you type a dot and then a space and then the name of the script; in Powershell that should be something like .\nameofscript.ps1.
      I realize that dot sourcing is causing some confusion and I will remove the requirement in the next version of the script (which should be coming any time soon).



      1. Hi Michael, thanks for the reply. I did get an error in Exchange Shell when executing ..\get-virdirinfo.ps1. do you have any idea? Thanks agin

        ..\get-virdirinfo.ps1 : The term ‘..\get-virdirinfo.ps1’ is not recognized as the name of a cmdlet, function, script
        file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
        and try again.

      2. 2 questions:
        1. have you typed a space between the first dot and the name of the script?
        2. are you running the cmd from the folder where the script is located?

  6. Ok, I have put a space after the first dot and it seemed to run. Then I ran the script with the filepath parameter but no report is created. Yes, I am running the cmd from the folder where the script is located… C:\Program Files\Microsoft\Exchange Server\V15\Scripts

    [PS] C:\Program Files\Microsoft\Exchange Server\V15\scripts>. .\get-virdirinfo.ps1
    [PS] C:\Program Files\Microsoft\Exchange Server\V15\scripts>.\get-virdirinfo.ps1 -filepath c:\reports
    [PS] C:\Program Files\Microsoft\Exchange Server\V15\scripts>.\get-virdirinfo.ps1
    [PS] C:\Program Files\Microsoft\Exchange Server\V15\scripts>


  7. If i run the script from the prompt it runs fine, however if i run it as a scheduled task it gives me; Connecting to remote server failed with the following error message : The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is usually returned by a HTTP server that does not support the WS-Management protocol. For more information, see the about_Remote_Troubleshooting.
    I ran the EMTShooter and everything is fine.

    I cant seem to find the difference between running in manualy and automatically.

    1. Hey Edwin, that is interesting…. Allow me some time to test this particular scenario and get back to you.
      Can you send me the information on the scheduled task so I can replicate in my lab(s)?


      1. This is how the script runs as a scheduled tasks:
        C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command “. ‘C:\_Scripts\Exchange\Get-VirDirInfov1.6.ps1′”

  8. I’m so sorry to have to ask, and I’m left feeling a little silly here, but when I try to run this script from the EMS, using ‘.\scriptname.ps1 -filepath C:\path’, it just very quickly returns me to the prompt. No errors to key off of, and no html report. I’m trying to run this against a single server 2010 organisation in preparation for an upgrade to 2013. Any ideas??

    1. Hey Jon,

      have you “dot-sourced” the script first? There was a time when I thought that was the way to go and I haven’t revisited the script since…
      It’s on my ever-growing to-do list though…


      1. I tried ‘dot sourcing’, that didn’t work. However, I read through the other comments and then found your suggestion to append to the end of the file “Get-VirDirInfo -filepath”, so I did that, saved it and then ‘dot sourced’ it again and it worked a charm. So thank you for the lovely script, and thank you for your very prompt reply, much appreciated.

  9. hello michael
    i use this script in my environment in the past and get all my exchange info like it should.
    i have 2 exchange 2010 and new exchange 2016.
    when i run the script i get only the information of my exchange 2010 server.
    do you know a reason for that ?

  10. hi michel

    i have 2 exchange 2010 servers and 1 exchange 2016.
    in the past i seceded to run this script and get all the servers information.
    now when i run this script i get only the exchange 2010 info.
    can you help me please ?