How To Get SharePoint Site and Web Guids   Leave a comment

I received a request to export a list of all SharePoint Site Collection GUIDs. Each Site Collection (Site)and Sub-Site (Web) contains a GUID (Global Unique Identifier).

This script below will enumerate through a Web Application and export the Site Guids to a
Comma Delimited File (.csv).

Simply copy this script and Save as SP-ExportSiteAndWebGuids.ps1

#* Author: Paul D. Fox
#* Date: 07/04/2013
#* Description: PowerShell Script to List Site and Web GUIDs.
#* Purpose: This PowerShell Script will Export all of the SharePoint Site and Web GUIDs to a
#* Comma Delimited file.
#* Modifications: MM/DD/YYYY – Description
#* Execution: To run this script Open the PowerShell Snap-in navigate to the directory where
#* this script resides and type the following: .\SP-ExportSiteAndWebGuids.ps1
#* Note: List must reside prior to executing this script

#Reference the SharePoint Assembly

### Begin Variables ###
$webApplicationUrl=Read-Host `n`n”Type the Url of the Web Application you wish to get Site and Web GUIDs”`n
### End Variables ###

#Set Output File
set-variable -option constant -name out -value “C:\DisplaySiteWebGuids.csv”

$webapplication = Get-SPWebApplication $webApplicationUrl

#Enumerate each Site (Site Collection)
foreach($site in $webapplication.Sites){
#Enumerate each Web (Site)

foreach($web in $site.AllWebs){
write-host $web.title “:” $spweb.URL
write-host $
“Web Title: ” + $web.title | Out-File $out -Append
“Web : ” + $web.Url | Out-File $out -Append
“Web Id: ” + $ | Out-File $out -Append
Write-Host “Script Completed!”


Posted July 26, 2013 by Bismarck in PowerShell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: