Guest User

Untitled

a guest
Nov 28th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. $webURL = "https://tenant.sharepoint.com/sites/PowershellTestingSite"
  2. $adminUrl = "https://tenant-admin.sharepoint.com"
  3. $userName = "user@tenant.onmicrosoft.com"
  4. $members = "i:0#.f|membership|SecureUser@tenant.onmicrosoft.com"
  5. # Let the user fill in their password in the PowerShell window
  6. $password = ConvertTo-SecureString "tenantpassword" -AsPlainText -Force
  7.  
  8.  
  9. $SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
  10.  
  11. # Creating client context object
  12. $context = New-Object Microsoft.SharePoint.Client.ClientContext($webURL)
  13. $context.credentials = $SPOCredentials
  14. $web = $context.web
  15. $context.load($web)
  16.  
  17. $web.breakroleinheritance($false, $false)
  18. $web.update()
  19.  
  20. #send the request containing all operations to the server
  21. try
  22. {
  23. $context.executeQuery()
  24. write-host "info: Broken inheritance for $($web.title)" -foregroundcolor green
  25. }
  26. catch
  27. {
  28. write-host "info: $($_.Exception.Message)" -foregroundcolor red
  29. }
Add Comment
Please, Sign In to add comment