vDiagram - Draw your VI with one script

Every good blog post should have some real life story to help you visualise why things happen so here goes:

The Story
One day whilst sat in the office updating the disaster recovery documentation I needed to document the Virtual Infrastructure, we all know that managers like pretty pictures so the first thing they asked for was a pretty diagram of how the infrastructure looked.

After dropping my 40th VM object on the page I started to get a bit bored, i looked at other options.  There is already a great tool on the market that performs this job, Veeam Reporter produces multiple documents and does a great job, but being a contractor I have a nil budget.  Knowing that you can do some very cool things with Powershell I wondered how easy it would be to hook into the Visio com object to get powershell to create the document for me.

As it turns out it wasn't that hard, there were a few sticky moments where I had to refer to the Visio forums, and a great starting point by the only powershell reference using Visio I could find (Check out CommandBreak_ Thanks Joeseph) after explaining what powershell was to the guys in the Visio Forum and explaining why I was using powershell as I think this is the first time these people had heard of it, I started to relate some of there c# examples back into powershell.

The Result
The result is by no means a totally polished all singing all dancing documenter that documents your VI from the left, from the right and upside down but what it is, is an example of what you can do with the Visio COM objects and powershell combined.

I have not yet included all the options I would like, in future versions I would like to be able to document the networking setup / storage paths etc but I'm working on something else so wanted to get this script out into the public.

Instructions
You will need:
  • Powershell V1 (I haven't tried it on V2 yet)
  • The VI Toolkit
  • Microsoft Visio (I have only tried 2003 +)
How to use:
  1. Download the zip file from the bottom of this page
  2. Once extracted copy the  'My-VI-Shapes.vss' file to your 'My Documents\My Shapes' folder.  If the folder does not exist create it and copy the file in.
  3. Run the powershell script with the following options:

To diagram the entire Infrastructure:

vDiagram.ps1 -VIServer MYVISERVER

To diagram a specific cluster use the following:

vDiagram.ps1 -VIServer MYVISERVER -Cluster "Production Cluster'

Example Output




The Download