Created
March 24, 2018 10:54
-
-
Save vgrem/eb70dc6f1b6d4510c8eea630ef990ac3 to your computer and use it in GitHub Desktop.
Retrieve sub webs within a site collection
This file contains hidden or 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
function Get-SPOWebs(){ | |
param( | |
$Url = $(throw "Please provide a Site Collection Url"), | |
$Credential = $(throw "Please provide a Credentials") | |
) | |
$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url) | |
$context.Credentials = $Credential | |
$web = $context.Web | |
$context.Load($web) | |
$context.Load($web.Webs) | |
$context.ExecuteQuery() | |
foreach($web in $web.Webs) | |
{ | |
Get-SPOWebs -Url $web.Url -Credential $Credential | |
$web | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Vadim,
How will you be able to get the count of all the subsites (all levels) and be able to export the information to CSV in the format (Site Coll URL | Subsite URL) using the recursive function call. I tried using a counter and returning it in the function but no luck. Please let me know if you can help.