Tuesday 11 March 2014

SharePoint 2010 PowerShell script to create a Visio Site Map

The script below creates a csv file output that can be used in Visio 2010 to create a site map. The usage is:

.\get-webinventory.ps1 -siteurl <url of site> | export-csv -NoTypeInformation -Path<file location>


To get Visio chart perform the following:

1.Log on to the SharePoint Server
2.Open Powershell, cd to script locationRun .\get-spwebinventory.ps1 -url <siteurl> | export-csv -NoTypeInformation -Path <csv file>
3.Copy the output file to your workstation with Visio 2010 installed
4.Open Visio and create an Org Chart
5.Click the Org Chart tab and click Import
6.Click "Next", "Text or Excel File", Browse to output file csv, Next
1.Name: ID
2.Reports to: ParentID
3.First Name: RelativeUrl
7.Next
8.Display Fields: RelativeUrl
9.Next
10.Move all columns to Shape Date Fields
11.Next
12.Click "I want to specifiy....."
13.Next, Finish

Once the chart has been create, subordinate format can be changed by right clicking the parent and choosing "Arrange Subordinates"




Script: get-webinventory.ps1


# COMMENTS: This script will be used to get a list of lists and counts for
# a site url. It will traverse the URL and go though the subsites
# as well.
#
# ————————————————————————
#

param ($url)

Function Get-WebSiteInventory{
    Param([string]$url)
    $site = get-spsite $url
    foreach ($web in $site.AllWebs) {
        $LastModified = $Web.LastItemModifiedDate
        $SnapShot = (get-date)
        $LastUpdate = ($SnapShot – [datetime]$LastModified)
        [uri]$weburl = $web.url
        $relativeurl = ($web.url).replace(($web.site.url),"")
        $data = @{
            Site = $web.title
            URL = $web.url
            "RelativeURL" = $relativeurl
            ID = $web.ID
            ParentID = $web.ParentWebID
            Last Modified = $web.LastItemModifiedDate
            Snaphost Date = $SnapShot
            Last Update = $LastUpdate.Days
            "HasUniquePerms" = $web.HasUniquePerm
            "Owners Group" = $web.AssociatedOwnerGroup
            "Group Count" = ($web.groups).count
        }
        New-Object PSObject -Property $data
        $web.Dispose();
    }
    $site.Dispose()
}

If ((Get-PsSnapin |?{$_.Name -eq "Microsoft.SharePoint.PowerShell"})-eq $null)
{
    $PSSnapin = Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null
}

Get-WebSiteInventory $url 

No comments:

Post a Comment