SHARE
TWEET

Untitled

a guest Dec 15th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top