I have an Office 365 group added, for e.g. "ABC" which could be present at any of the below level. Permissions are broken at any level below

  Document Library
    Page 1
    Page 2

I need to replace this Office 365 group with another one for e.g. "DEF". Using Powershell, i can remove the user from the site collection. But because i do that, the user is removed from all places, then i cant find out where the user was present and replace them.

          $usrold =$web.SiteUsers.GetByLoginName($O365GroupOld)
          $roleDefinition = $ctx.Site.RootWeb.RoleDefinitions.GetByType([Microsoft.SharePoint.Client.RoleType]::Contributor)  
          $roleBindings = New-Object Microsoft.SharePoint.Client.RoleDefinitionBindingCollection($ctx) 
          $ctx.Load($web.RoleAssignments.Add($usernew, $roleBindings))

Can someone provide me a powershell script that can replace the Office 365 groups that exists at any level.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.