I'm trying to create custom permissions in my Sharepoint site via Powershell using the following script:

$spSite = Get-SPSite $url
$spWeb = $spSite | Get-SPWeb

foreach($option in $configuration.Config.permissions.permission)
    if($spWeb.RoleDefinitions[$option.name] -eq $null)
        $spRoleDefinition = New-Object Microsoft.SharePoint.SPRoleDefinition
        $spRoleDefinition.Name = $option.name
        $spRoleDefinition.Description = $option.description

        $spRoleDefinition.BasePermissions = $option.bases

And I keep receiving the following error:

Exception calling "Add" with "1" argument(s): "Collection was of a fixed size."
At C:\xxxx\xxxxxx\xxxxx:70 char:4
+             $spWeb.RoleDefinitions.Add($spRoleDefinition)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NotSupportedException

Thanks for the help.

2 Answers 2


I found the issue:

Instead of using $spWeb = $spSite | Get-SPWeb I used $spWeb = $spSite.RootWeb and it worked fine.


Try to run SharePoint Managment shell as a Administrator

  • Still not working
    – Marco
    Oct 29, 2015 at 10:58

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.