Created
September 19, 2018 10:44
-
-
Save tristian2/a9ac98e033386f074ca2917592ec6851 to your computer and use it in GitHub Desktop.
look at sites hierarchy and output as css, for further analysis in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear-host | |
#depict the site hierarchy, for further analysis in R or SPSS | |
#setup csv | |
Add-Content -Path C:\SiteStructure.csv -Value '"Node","Parent","Template"' | |
function GetAllWebs($url) | |
{ | |
try | |
{ | |
$w = Get-SPWeb -identity $url; | |
Write-Host ([String]::Format("Procesing web {0}",$w.Url)) -foregroundcolor Blue | |
if($w.Webs.Count -gt 0) | |
{ | |
foreach($web in $w.Webs) | |
{ | |
$row = "" + $web.Title+","+$web.ParentWeb+","+$web.WebTemplate | |
Add-Content -Path C:\SiteStructure.csv -Value $row | |
GetAllWebs $web.Url; | |
} | |
} | |
} | |
catch | |
{ | |
Write-Host ([String]::Format("Error processing web at $url, with Exception: {0}", $_.Exception.Message)) -foregroundcolor Red | |
} | |
} | |
$sites = Get-SPSite -webapplication 'https://www.xxx.org' -limit ALL; | |
foreach($site in $sites){ | |
#write-host $site.url | |
getAllWebs $site.url | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment