1

I have just Migrated our SharePoint to O365 2013 and all the permissions seem to be messing up. I need to reset all the permissions to inherit from its parent. I have tried this script to no prevail.

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

#Variable for Web URL
$WebURL ="https://Bytescloud.sharepoint.com/"

#get Web object
$Web = Get-SPWeb $WebURL

#Get Lists with Unique permissions - Exclude Hidden lists
$ListColl =  $web.lists | Where-Object  { ($_.hidden -eq $false) }
#Enumerate through each list and reset permission inheritance  
foreach($list in $ListColl)
{
 #Reset list inheritance
 $list.ResetRoleInheritance()
 Write-host "Broken Inheritance Reset on List:" $list.Title

 $items = $list.Items | Where-Object{$_.HasUniqueRoleAssignments};
 foreach($item in $items)
 {
  #Reset broken list item inheritance
  $item.ResetRoleInheritance()
  Write-host "Broken Inheritance Reset on List Item:" $item.URL
 }
 #}
$folders = $list.Folders
if ($folders.Count -gt 0)
{
 foreach ($folder in $folders) 
 {
  if ($folder.HasUniqueRoleAssignments -eq $True)
  {
    $folder.ResetRoleInheritance()
    $folder.update()
  }
 }
}
}

Any help?

2 Answers 2

1

I found this blog helpful for the commands to reset permissions inheritance, as it mentions doing the the $web.update both before and after the $web.ReserRoleInheritance() command. Not sure why needed but doing both before and after worked for me:

http://scriptingsamurai.com/sharepoint-permissions-management/

0

You should use SharePoint client libraries to access a SharePoint site in Office 365. Please have a look here to get started. After installing the SharePoint Online Management shell you should be able to connect to a SharePoint online site with "Get-SPOSite". Here is also a example of how to work with groups and users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.