Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $webURL = "https://tenant.sharepoint.com/sites/PowershellTestingSite"
- $adminUrl = "https://tenant-admin.sharepoint.com"
- $userName = "user@tenant.onmicrosoft.com"
- $members = "i:0#.f|membership|SecureUser@tenant.onmicrosoft.com"
- # Let the user fill in their password in the PowerShell window
- $password = ConvertTo-SecureString "tenantpassword" -AsPlainText -Force
- $SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
- # Creating client context object
- $context = New-Object Microsoft.SharePoint.Client.ClientContext($webURL)
- $context.credentials = $SPOCredentials
- $web = $context.web
- $context.load($web)
- $web.breakroleinheritance($false, $false)
- $web.update()
- #send the request containing all operations to the server
- try
- {
- $context.executeQuery()
- write-host "info: Broken inheritance for $($web.title)" -foregroundcolor green
- }
- catch
- {
- write-host "info: $($_.Exception.Message)" -foregroundcolor red
- }
Add Comment
Please, Sign In to add comment