magritton
4/25/2014 - 11:44 AM

This SharePoint powershell script will list all the web application,, sites, and lists in a farm and output the results in digestible XML

This SharePoint powershell script will list all the web application,, sites, and lists in a farm and output the results in digestible XML

#c:\temp\sitemapgen | Export-CliXML c:\temp\test.xml
#c:\temp\sitemapgen > c:\temp\test.xml
#c:\Packages\sitemapgen > \\OPWSQL03\SSISDataDump\SpSiteMap.txt
$ver = $host | select version
if ($ver.Version.Major -gt 1)  {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell
Set-location $home

$WebApps=Get-SPWebApplication
"WebURL|WebTitle|ListTitle|ListURL|ListID|WebID|ParentWebID"
foreach($webApp in $WebApps)
{
$wa = Get-SPWebApplication $webApp.URL
        $allSites = $wa | Get-SPSite -Limit all
        foreach ($spsite in $allSites) {
            $allWebs = $spsite.allwebs
            foreach ($spweb in $allWebs) {
            #$spweb.Url 
            foreach($list in $spweb.lists)
               {
                $spweb.Url + "|" + $spweb.Title + "|" + $list.Title + "|" + $list.RootFolder.Url + "|" + $list.ID + "|" + $spweb.ID + "|" + $spweb.ParentWebID
               }
            #$spweb.Lists | select Title,BaseType

            $spweb.dispose()
            }
        }
 
}
#c:\temp\sitemapgen | Export-CliXML c:\temp\test.xml
#c:\temp\sitemapgen > c:\temp\test.xml
#c:\Packages\sitemapgen > \\OPWSQL03\SSISDataDump\SpSiteMap.txt
$ver = $host | select version
if ($ver.Version.Major -gt 1)  {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell
Set-location $home

$WebApps=Get-SPWebApplication
"WebURL|WebTitle|WebID|ParentWebID"
foreach($webApp in $WebApps)
{
$wa = Get-SPWebApplication $webApp.URL
        $allSites = $wa | Get-SPSite -Limit all
        foreach ($spsite in $allSites) {
            $allWebs = $spsite.allwebs
            foreach ($spweb in $allWebs) {
                $spweb.Url + "|" + $spweb.Title + "|" + $spweb.ParentWebID
               }
            $spweb.dispose()
            }
 
}