Skip to content

Instantly share code, notes, and snippets.

@tristian2
Created September 19, 2018 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tristian2/a9ac98e033386f074ca2917592ec6851 to your computer and use it in GitHub Desktop.
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
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