Wow that’s a long title. To summarise:
PowerShell script = SCCM Visio diagram

If you have many different SCCM hierarchies in different AD domains and forests to manage, keeping relevant/up to date infrastructure diagrams can be time consuming, especially if there are lots of SCCM site systems, Visio can become painful to use.

I have put this script together: SCCM Visio diagram.ps1 with the help of colleague Ben Jones (especially for the maths parts) that automatically creates a Microsoft Visio diagram of your SCCM / ConfigMgr hierarchy.

I know there are tools like the CMMap / SMSMap ones, but the SMSMap one in particular is using older shapes, has not been tested with SCCM 2012+ or Visio 2013+. I noticed it was also creating duplicate servers for each role! which is a fairly big overhead when you have 100’s of roles.

I wanted to see an open source script that could be used on a schedule to automate the diagram creation. Some further design requirements :

  • User running script needs read only access to the SCCM reporting point. No SQL or SMS Provider/WMI access is required!
  • Only HTTP/HTTPS ports are used by the script
  • Shapes can easily be swapped out for a new stencil set if required
  • Diagram scales from huge to tiny SCCM environments
  • Custom shape data can be added to each object from an additional external source (like a corporate CMDB API)

Pre-reqs before running the script :

  • Microsoft Office Visio 2016 Standard or Professional must be installed on the machine from where the script is run. (Sorry, I know a license is required - I haven’t tested with the trial version)
  • Download and extract SCCM Visio stencils and then adjust line 12:
# Custom SCCM Stencils used for building the infrastructure diagram  
$SCCM_Servers_Stencil_Path="\\domain.local\shares\files\visio\it\ConfigMgr\1610\Visio\Stencils\v1.3\ConfigMgr 1610 (Servers).vss"  
  • Network access to the HTTP/HTTPS port of the top level SCCM Reporting services point site
  • SCCM Reporting Reader rights with access to these two reports:
$SCCM_SiteRoles_ReportName = 'Site system roles and site system servers for a specific site'  
$SCCM_SiteStatus_ReportName = 'Site status for the hierarchy'  
  • Adjust the following variable on line 9 to the FQDN of your top level SCCM reporting server:
$SCCM_SSRS_FQHostname = "SCCM-RP.domain.local"; # Central Administration Site reporting point  

Some quick notes on the workings of the script :

  • It’s using the Visio.Application COM object. You can use the developer mode in Visio to find out more about VBA
  • It has only been tested with en-gb language code 2057 in Visio. Try amending line 657 ($visCustPropsLangID) for diff languages.
  • The US version of SCCM Reporting Point was used. The names of the two reports mentioned above could be adjusted
  • Lines 726-745 are for when you want to use a custom API to retrieve additional info about your servers and add it the Visio shape data. I got lazy and didn’t add an optional variable to run this or not so you’ll probably want to remove this section to avoid errors at the end of the script.

Zoomed out to 30% in Visio - the whole overview. 5 Primary sites and a CAS. SCCM Visio Diagram 1

Zoomed to about 70% so you can see each site system has the roles, IP and server name as the text box description below the shape: SCCM Visio Diagram 2

A short YouTube video of how things look as Visio is processing the shapes passed from the PowerShell script: Automatic Visio diagram video

Thanks to Jean-Sébastien DUCHÊNE for the cool SCCM Visio stencils.

And again, huge thanks to Ben Jones for his mathematical skills and converting these to .net/PowerShell to get the correct spacing for each shape.

Any questions please ping me on Twitter @JackRudlin