Guest User

Untitled

a guest
Dec 15th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Site
  2. Document Library
  3. Pages
  4. Page 1
  5. Page 2
  6. SubSite
  7.  
  8. $usrold =$web.SiteUsers.GetByLoginName($O365GroupOld)
  9. $ctx.Load($usrold)
  10. $ctx.ExecuteQuery()
  11. $web.SiteUsers.Remove($usrold)
  12. $ctx.ExecuteQuery()
  13. $usernew=$web.EnsureUser($O365GroupNew)
  14. $ctx.Load($usernew)
  15. $ctx.ExecuteQuery()
  16. $roleDefinition = $ctx.Site.RootWeb.RoleDefinitions.GetByType([Microsoft.SharePoint.Client.RoleType]::Contributor)
  17. $roleBindings = New-Object Microsoft.SharePoint.Client.RoleDefinitionBindingCollection($ctx)
  18. $roleBindings.Add($roleDefinition)
  19. $ctx.Load($web.RoleAssignments.Add($usernew, $roleBindings))
  20. $ctx.ExecuteQuery()
Add Comment
Please, Sign In to add comment