As the question basically says, is there a way to stop permissions inheritance after create a new website using powershell? Thanks a lot!

3 Answers 3


Since SharePoint 2013/Online supports a several sets of APIs, it depends which API you prefer:

  • CSOM
  • REST
  • SharePoint Web Sevices

How to break permissions inheritance for web site using CSOM

Prerequisite: download and install SharePoint Online Client Components SDK


Function Get-ClientContext([string]$Url,[string]$UserName,[string]$Password)
    $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
    $context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
    $context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
    return $context

Function Web-BreakInheritance([Microsoft.SharePoint.Client.Web]$Web)
     $Web.BreakRoleInheritance($true, $false)


How to break permissions inheritance for Blogs site:

$UserName = "[email protected]"
$Password = Read-Host -Prompt "Enter the password"    
$Url = "https://contoso.sharepoint.com/blog"

$context = Get-ClientContext -Url $Url -UserName $UserName -Password $Password
Web-BreakInheritance -Web $context.Web

There is a property you can pass called UseSamePermissionsAsParentSite

$newWeb = New-Object Microsoft.SharePoint.Client.WebCreationInformation
$newWeb.Url = 'someURL'
$newWeb.UseSamePermissionsAsParentSite = $false
$newWeb.Title = 'Some Web'
$newWeb.WebTemplate = "STS#0"
$spWeb = $ctx.Web.Webs.Add($newWeb)

Their is no easy way to break the inheritance in SPO as limited number of powershell cmdlt avaiable. Check this one : http://sharepointweblog.blogspot.com/2015/03/office-365-create-site-using-custom.html

But their is one custom script written for lists, You have to tweak this solution and run it after new site created.

Powershell script to break inherited permissions for all SharePoint Online lists in a site collection. Before you run it, you have to modify one last line of the script!https://gallery.technet.microsoft.com/office/Break-inheritance-for-all-ded251fa

function Set-SPOListBreakRoleInheritance

   param (

   $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
  $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
  $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
  Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen
  foreach( $ll in $ctx.Web.Lists)

        $ll.BreakRoleInheritance($true, $false)

        Write-Host "Removed inherited permissions for " $ll.Title
        Write-Host "Failed to remove permissions for " $ll.Title


  if($ctx.Web.Webs.Count -gt 0 -and $IncludeSubsites)
    for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++)
        Set-SPOListBreakRoleInheritance -Url ($ctx.Web.Webs[$i].Url) -Username $Username -AdminPassword $AdminPassword -IncludeSubsites $IncludeSubsites



# Paths to SDK. Please verify location on your computer.
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" 
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" 

Set-SPOListBreakRoleInheritance -Username "[email protected]" -Url "https://trialtrial123.sharepoint.com" -AdminPassword "Pass" -IncludeSubsites $false 
  • This will work for on prem but the question was for SP Online (I think)
    – Bunzab
    May 6, 2015 at 17:36
  • this is for SPO.
    – Waqas Sarwar MVP
    May 6, 2015 at 17:41
  • 1
    It is now that you have changed it yes...
    – Bunzab
    May 6, 2015 at 17:50

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.