<

Create A Visio SharePoint Site Map And Document Count (SharePoint 2007, SP2010, & SP2013)

Published on
11,524 Points
5,324 Views
2 Endorsements
Last Modified:
Approved
One of the most challenging things I've run into as a SharePoint consultant is creating a visual sitemap of a SharePoint environment.  Visual maps are so much more effective when showing clients what their environment looks like and how it can be optimized when performing a migration, security review, or consolidation effort.  My inspiration for publishing this article is hoping it will provide others in the same position an easy way to get a visual overview of their SharePoint environment.
1.png*NOTE: The yellow colored objects were manually set. I try to get only 1 row of pages in Visio. If any go beyond 1 row, I put them in a different Visio sheet and uniquely identify that node by changing the color.
 
Run this PowerShell script.
  • By default it uses the local SharePoint environment so it should be run on the SP server itself.
  • If you want to specify a specific WebApplication, you can modify the script. 
  • This was written for WSS 3.0 and MOSS 2007 to run using PowerShell 1.0 because that's what many companies are migrating from.  For 2010 and 2013 I'm aware there are optimizations that could be made to the script
The script is commented but is pretty straight forward.
 
#clear the PowerShell window
cls

#Set or reset default properties
$ReportPath = "SPSiteReport.csv"
$Result=""
$Count=0

#Load the PowerShell commandlets for SharePoint using PowerShell 1.0 and MOSS 2007 compatibility
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local

#Print the header in the resulting file
$Header = " `tCount`tTitle`tURL`tType`tID`tParent"
Out-File -inputobject $Header -filepath $ReportPath -Force


    foreach ($spService in $farm.Services) {
        if (!($spService -is [Microsoft.SharePoint.Administration.SPWebService])) {
            continue;
        }
        
        foreach ($webApp in $spService.WebApplications) {
            if ($webApp -is [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]) { continue }

            foreach ($site in $webApp.Sites) {
				
                foreach ($web in $site.AllWebs) {
                
					foreach ( $List in $Web.Lists )
                    {
						#Get the count of items in the current list
                        $Count = $Count + ($List.Folders.Count + $List.Items.Count)
						Write-Progress -activity "Inventorying items. . ." -status "Processing items in Site> $web - List> $list"
                    }
					#Output the result of the current list
                    
					$Result = " " + "`t" + $Count + "`t" + $Web.Title + "`t" + $Web.URL + "`t" + $List.BaseType + "`t" + $web.ID + "`t" + $web.ParentWebID
					
					Out-File -inputobject $Result -filepath $ReportPath -append
					
					#Reset the item counter
                    $Count=0
                }
            }
        }
    }

Open in new window


Short and simple but VERY effective. If you don't need document counts, you can comment out the inner-most foreach loop that spins through each list.  However, you'll have to also modify the $Header (at the top where the column headers are written) and $Result (after the inner-most foreach where the values are saved) to remove the Count value.  
 
After running the script, you will have a csv file that will contain the information exported from the script. Now, open MS Visio and create a new Organizational Chart. I'm using Visio 2013.
 
2.png 
Since we have the CSV file already, use the option for "Information that's already stored in a file or database"
3.pngSelect the text document
4.png 
Browse to the file that the script created
5.png 
Here, you want to have the fields setup as follows:
Name: ID
Reports To: Parent
First Name: Title
This takes the columns it found in the csv file and is asking you how it is organized hierarchically. The ID and Parent are the GUIDs of the sites showing the lineage. The First Name is the name of the respective site
6.png 
These display fields are good to get setup the first time. I don't use the Parent or ID fields in my display because they are just GUIDs. I order the displayed fields to show Title, Count, Type, and finally URL:
7.pngBecause you're displaying the above fields, you have to also give them a display shape. Also, because the ID is required, it too will have a place on the chart, thus overriding the previous step (with sarcasm... "thanks Microsoft").
8.png 
You probably don't have nor want to include pictures of each site in the chart and actually, we'll be hiding the picture field once this is done.
9.pngThis step is sometimes tricky. Most of the time I can just hit "Finish" and it will build the sitemap perfectly. However, there were occasions where I had to just hit the dropdown and then press finish.
 
I generally choose the second option because Visio will build separate sitemaps for different subsites. However, if you want to have the entire sitemap built on one sheet for you to split if necessary, select the first option. 
10.pngWhen I had to click the dropdown, I was given this dialog box. Press "Yes"
11.png 
Visio will now build the sitemap. 
 
To remove the empty picture object and gain more real estate for the text, select all the shapes (ctrl+a), right click on one of the shapes and select, "Picture" --> "Hide Picture" or "Delete Picture"

There you go!  A beautiful site map of your SharePoint environment.
1.png
2
Comment
Author:skipper68
0 Comments

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Join & Write a Comment

Key to your CPU's ability to stay cool is to use the right amount of thermal paste and apply it correctly. In other words you want as much thermal conductivity between CPU and the cooling block. Use a quality thermal paste and apply it in a manner…
Watch this simple and effective video tutorial to extract attachments from Outlook 2007 and try this easy method by yourself. No need to go anywhere, just watch the video and export attachments from Outlook in few simple steps. To know more, click h…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month