Tell me more…

It’s been about 573 days or almost 75 weeks since I originally published my blog post titled “Making sense of a TBXML” which included a PowerShell script that could parse the data from a Lync Topology Builder file and create a spreadsheet and Visio diagram. I’ve published a few blog posts since then with new scripts, but never stopped working on improving my Lync Documentation Script. It has grown immeasurably in complexity and capability since then.

Before I get into all the gory details, I’d like to thank a few people for their help along the way. Thank you to Pat Richard and Luke Kannel who helped test out the earlier versions and provided invaluable feedback on bugs, fixes, and features. I’d also like to thank the guys over at DigiCert for their help in getting me a code signing certificate so all of these scripts could be signed. And last but certainly not least a giant thank you to Tim Harrington who spent a stupid amount of hours testing, validating, and providing great feedback.

All right, let’s get down to business. One huge change from the previous documentation script is that the TBXML is not the primary source of data anymore. It has a lot of great information stored in it, but still comes up lacking when you want to include things like certificate data and software versions. To get around this limitation the original script was broken into three smaller scripts.




This is the heart and soul of the tools as it does the data collection and sorting. It’s fairly straightforward and only has one command-line option which is -EdgeCredentials. The command-line option is to specify the non-domain credentials for connecting to the Edge server(s) for more enhanced data collection for things like CPU Core Count, RAM totals, and Certificates. If you don’t specify Edge Credentials the script will prompt you to enter them, if you cancel the credential prompt the script will continue and still pull some limited data for the Edge servers.

I typically run this from one of the Front-End servers as it will require the Lync PowerShell tools. The other thing that is required is the ability to do DNS lookups against an external DNS server, so UDP 53 outbound. Get-Help context is available for the scripts, but it should be pretty straightforward.


This will produce a zip archive containing an XML file with all of the environment data. You will need to copy the zip file to a workstation that has Word and Visio installed to run the next two scripts for report generation. My testing and validation was done on Windows 7 with Office 2010 and Office 2013. It should work with Windows 8, and may work with older versions of Office.



This script will build a Word document from the data package collected from the above script. The only command-line option for this and the Visio script below is -LyncDataFile which is used to provide the file name for the file created with the Get-LyncInfo.ps1 script. If you don’t specify the data package file name at the command-line the script will show the Open File dialog.

One huge caveat with the Word report creation script and the Visio script below is that if you move the mouse cursor in the window during creation it will break the process and mess up the reports.There’s not much else to configure or change.




Again this script will accept the -LyncDataFile command-line option to specify the data file to build from, if you don’t specify a data file the script will present the Open File dialog. Again, there’s not much else to configure or change. This script does require the Office/Exchange/Lync 2013 Visio stencil pack to be in your “My Documents\My Shapes” folder. Don’t worry if you don’t have it downloaded, Pat Richard has been so gracious as to provide a section of the script that will download and place them in the correct folder.

Be extremely careful not to click in or on the Visio or PowerShell windows while it’s running. I know it seems weird but something within PowerShell and/or Visio does not like it, specifically the AutoConnect method on the Pool to Site connectors will error out. I might have  been able to bypass this by keeping the Visio window hidden during the drawing process, but it’s kind of cool to watch it work.



You can download a zip file containing the scripts from the TechNet gallery at the link below.

Download Here

18 thoughts on “Tell me more…

  1. Nice script. But iv run into a few errors running Get-LyncInfo.ps1 and New-LyncEnvReport.ps1. The first script while it did complete produced two errors:

    Add-Member : Cannot add a member with the name “Edge External” because a member
    with that name already exists. If you want to overwrite the member anyway, use
    the Force parameter to overwrite it.
    At C:\Scripts\Lync Env Report\Get-LyncInfo.ps1:391 char:14
    + Add-Member <<<< -InputObject $MachineCertificates -MemberType No
    teProperty -Name "$($CertUse)" -Value $CertificateToStore
    + CategoryInfo : InvalidOperation: (@{Edge External…ions.Hashta
    ble}:PSObject) [Add-Member], InvalidOperationException
    + FullyQualifiedErrorId : MemberAlreadyExists,Microsoft.PowerShell.Command

    This error is likely because my certificate is named "Edge External". The second error was:

    Get-CsKerberosAccountAssignment : Cannot find "KerberosAccountAssignment" "Site
    :1" because it does not exist.
    At C:\Scripts\Lync Env Report\Get-LyncInfo.ps1:680 char:63
    + $SiteKerberosConfiguration = Get-CsKerberosAccountAssignment <<<< -I
    dentity "Site:$SiteName" | Select -Expand UserAccount
    + CategoryInfo : ResourceUnavailable: (Site:1:String) [Get-CsKerb
    erosAccountAssignment], KeyNotFoundException
    + FullyQualifiedErrorId : MissingItem,Microsoft.Rtc.Management.Internal.Ge

    The script went onto to complete and create the contents in the zip/xml file.
    When running the latter command New-LyncEnvReport.ps1 on my desktop PC (Win 7 with Office 2013 and Visio 2010) it produced the following exception and did not complete:

    Exception calling "get_Cells" with "1" argument(s): "
    Unexpected end of file."
    At C:\Users\shawn\Desktop\Lync Env Report\New-LyncEnvDiagram.ps1:472 char:15
    + $SiteBG.Cells <<<< ("ShapeShdwBlur").Formula = "0 pt"
    + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordE
    + FullyQualifiedErrorId : DotNetMethodException

    Line 472 of the script contains: $SiteBG.Cells("ShapeShdwBlur").Formula = "0 pt".

    Any ideas on why i'm getting these errors? Bare in mind i'm running this script in a lab. Its a simple Std edition front end pool with one edge server and a reverse (TMG) proxy.

    • If you actually have quotes in the certificate name that may be causing the problem with it. I will look at adding escape characters to that section to account for that. The Kerberos related error is likely because you may not have Kerberos setup for that site. There is a Try/Catch option in that function that should handle the error, I will check the settings there again.

      As for the Visio error the “Shape Shadow Blur” option was not added until Visio 2013, which is why you’re seeing the error. I would comment out line 472 for now and try it again. I will remove that line from the script going forward.

  2. Chris – Or just read the uninstall string from the registry and see if Visio 2013 is install and IF/THEN. For the 32bit version, test-path HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{91150000-0051-0000-0000-0000000FF1CE}
    If it exists, Visio 2013 is installed. I would suspect that the 64bit version would show under HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{91150000-0051-0000-0000-0000000FF1CE}
    but don’t have it installed to test.

  3. I commented out that line but the script now fails on the following lines 473 and 475. Id guess its going to fail on all the lines where it calls a Viso 2013 feature. I’m using Visio 2010 though which is likely where this discrepancy lays. Any ideas?

  4. I upgraded my Visio installation to 2013 and the script now runs fine with no issues. I guess you may need to produce two versions of your script if you want to accommodate those using Visio 2010. Or failing that modify the code to ignore the 2013 lines where 2010 is present.

  5. Hi, great work. I have the Problem, that on Windows 8 with Office 2013 and Visio 2010 the script “New-LyncEnvReport.ps1” doesn’t work at all. 🙁
    It fails with the command “$global:WordDocument = $WordApplication.Documents.Add()”
    I’ using a german Version of Windows so posting the error message dosn’t make that much sense, but roughly it says, that it’s not possible to call a method with parameter is NULL…
    I tried it manualy in the Console. When creating a new ComObject (for Word) then the verbose Output Looks like this. Is that ok?
    Can you help me here? Thanks in advance. 🙂

    Application :
    Creator :
    Parent :
    Name :
    Documents :
    Windows :
    ActiveDocument :
    ActiveWindow :
    Selection :
    WordBasic :
    [and so on – all are empty]

    • There are some language localization issues with Office that create problems with automation scripts such as mine. I’m using the EN-US version of Office so that’s what I developed and tested against, but I am working to resolve these issues now.

  6. The report is great and I really appreciate you posting that up. I am having a problem running the script for Visio. Not sure if this is an issue with my environment or the file didn’t get created properly?
    “New-LyncEnvDiagram.ps1 : Exception getting “Cells”:
    Unexpected end of file.”
    At line:1 char:1
    + .\New-LyncEnvDiagram.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [New-LyncEnvDiagram.ps1], GetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenGetting,New-LyncEnvDiagram.ps1

  7. Hi Chris,

    great work, but I receive an error when executing the Visio script. It opens up Visio 2013 and gets the stencils but then quits with the following error.

    An exception occurred.”
    At line:1 char:1
    + .\New-LyncEnvDiagram.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [New-LyncEnvDiagram.ps1], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting,New-LyncEnvDiagram.ps1

    Any idea?
    Thanks and keep on creating your great scripts.

  8. I’m running Windows 8(64Bit) with office 2013(32-bit) and visio 2013(32bit) and getting this error with the visio script:
    C:\scripts\New-LyncEnvDiagram.ps1 : Exception getting “Cells”: ”
    Unexpected end of file.”
    At line:1 char:1
    + .\New-LyncEnvDiagram.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [New-LyncEnvDiagram.ps1], GetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenGetting,New-LyncEnvDiagram.ps1

    The visio diagram just hangs after that.

  9. Great script! Thanks for all your effort and sharing.

    The script runs so far for me then once it hits one of our sites (which isn’t fully deployed in to production yet, which might be the problem) I get the following error…

    Adding internal background for site Alberta Thermals.
    C:\powershell\LyncEnvReport\New-LyncEnvDiagram.ps1 : Exception setting “Formula”: ”
    At line:1 char:1
    + .\New-LyncEnvDiagram.ps1 -LyncDataFile “C:\powershell\LyncEnvReport\transalta.or …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [New-LyncEnvDiagram.ps1], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting,New-LyncEnvDiagram.ps1

    Any ideas on how I can get around this? I believe the issue is with the Alberta Thermals site, but not familar with xml to exclude that site information.


  10. Excellent work Chris, this is a very useful utility.

    I would recommend adding the following into the Powershell Script to allow it to check and load the Lync module if it is not already into Get-LyncInfo.ps1.

    IF (!(Get-Module Lync)) { Import-Module Lync }

    As a feature request, in New-LyncEnvReport.ps1, can you reformat the Accepted/Blocked Domains so that it is row based rather than column, as having more than 10 domains in columns is a bit difficult to read.

  11. Hi.

    Nice script 🙂
    Are getting error With New-LyncEnvDiagram.ps1
    D:\Dropbox\Lync\Lync Environment Report\New-LyncEnvDiagram.ps1 : Exception setting “Formula”: ”
    An exception occurred.”
    At line:1 char:1
    + .\New-LyncEnvDiagram.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [New-LyncEnvDiagram.ps1], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting,New-LyncEnvDiagram.ps1

    Any idea why ??

  12. Hi, i am having some problems getting the New-LyncEnvDiagram.ps1 to work, i am only getting this error:

    PS C:\tmp> C:\tmp\New-LyncEnvDiagram.ps1
    **Unable to locate specified file.**
    Opening file picker for data file selection
    Importing Lync data file to
    Folder: “\\storage.domain.com\home\me\My Documents\My Shapes” exists.
    File: FLEX_Stencil_112012.vss exists.
    *** Starting Time: 03/26/2013 13:29:24 ***
    Creating diagram: C:\tmp\domain.comLync_Env_Data-0326131208.vsd
    Creating new instance of Visio to work with.
    Creating new Visio document.
    Adding pages to work with.
    Importing stencils.
    Adding internal background for site MYSITE.
    C:\tmp\New-LyncEnvDiagram.ps1 : Exception setting “Formula”: ”
    An exception occurred.”
    + CategoryInfo : NotSpecified: (:) [New-LyncEnvDiagram.ps1], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting,New-LyncEnvDiagram.ps1

    Any ideas about what might be the problem ?


Leave a Reply

Your email address will not be published. Required fields are marked *