Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Script variables
- $targetWebUrl = "https://XXX.sharepoint.com"
- $login = "XXX@XXX.fr"
- function GetSubWebs($ctx, $web)
- {
- $allWebs = $web.Webs
- $ctx.Load($allWebs)
- $ctx.ExecuteQuery()
- foreach($w in $allWebs)
- {
- $t = $w.Title
- $u = $w.Url
- "$t`t$u"
- GetSubWebs $ctx $w
- }
- }
- cls
- $scriptFolder = "XXX"
- Set-Location $scriptFolder
- Import-Module "../Microsoft.SharePoint.Client.dll"
- Import-Module "../Microsoft.SharePoint.Client.Runtime.dll"
- # SharePoint online credentials
- $SecurePassword = Read-Host -Prompt "Enter password" -AsSecureString
- $myCred = New-Object "Microsoft.SharePoint.Client.SharePointOnlineCredentials" -ArgumentList @($login, $SecurePassword)
- $ctx = New-Object "Microsoft.SharePoint.Client.ClientContext" -ArgumentList @($targetWebUrl)
- $ctx.Credentials = $myCred;
- $web = $ctx.Web #.AllWebs
- $ctx.Load($web)
- $ctx.ExecuteQuery()
- $t = $web.Title
- $u = $web.Url
- "$t`t$u"
- GetSubWebs $ctx $web
- $ctx.Dispose()
- "===== END ====="
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement