Skip to main content
Post Reopened by Mohamed El-Qassas MVP
deleted 102 characters in body; edited tags; edited title
Source Link

Powershell add SharePoint group to list "Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment" in PowerShell

I'm trying to add a SharePoint group to a specific list that exists on all the sites in a collection. I would think this would be easier but I'm having difficulties. Inheritance is already broken on the list. 

Below is my code and then the error I'm getting. (This is not a duplicate question as the fix was different than what the suggested thread was solved by)

$siteNumbers = "2210"
$listsOnSite = "QWERTY"

Foreach($wnl in $siteNumbers)
    {
    $rootWeb = (Get-SPWeb ("http://url/to/site/" + $wnl))

    
    Foreach($lst in $listsOnSite)


    {
    $list = $rootWeb.Lists[$lst]
    $group = $rootWeb.Groups["Global Read-Only QWERTY"]
    $role = $rootWeb.RoleDefinitions["Read"]

    $roleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
    $RoleAssignment.RoleDefinitionBindings.Add($role)
    $rootWeb.RoleAssignments.Add($RoleAssignment)
    $list.RoleAssignments.Add($roleAssignment)
    $list.Update()
    }
    $rootWeb.Update()
    }
    

New-Object : Constructor not found. Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment. At line:9 char:33

  • $roleAssignment = New-Object <<<<  Microsoft.SharePoint.SPRoleAssignment( $group)
    
    • CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentExce ption
    • FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.C
      ommands.NewObjectCommand

Exception calling "Add" with "1" argument(s): "The permission level specified i s already added to the collection." At line:10 char:47

  • $RoleAssignment.RoleDefinitionBindings.Add <<<< ($role)
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression. At line:12 char:30

  • $list.RoleAssignments.Add <<<< ($roleAssignment)
    
    • CategoryInfo : InvalidOperation: (Add:String) [], RuntimeExcept ion
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At line:13 char:17

  • $list.Update <<<< ()
    
    • CategoryInfo : InvalidOperation: (Update:String) [], RuntimeExc eption
    • FullyQualifiedErrorId : InvokeMethodOnNull

Powershell add SharePoint group to list

I'm trying to add a SharePoint group to a specific list that exists on all the sites in a collection. I would think this would be easier but I'm having difficulties. Inheritance is already broken on the list. Below is my code and then the error I'm getting. (This is not a duplicate question as the fix was different than what the suggested thread was solved by)

$siteNumbers = "2210"
$listsOnSite = "QWERTY"

Foreach($wnl in $siteNumbers)
    {
    $rootWeb = (Get-SPWeb ("http://url/to/site/" + $wnl))

    
    Foreach($lst in $listsOnSite)


    {
    $list = $rootWeb.Lists[$lst]
    $group = $rootWeb.Groups["Global Read-Only QWERTY"]
    $role = $rootWeb.RoleDefinitions["Read"]

    $roleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
    $RoleAssignment.RoleDefinitionBindings.Add($role)
    $rootWeb.RoleAssignments.Add($RoleAssignment)
    $list.RoleAssignments.Add($roleAssignment)
    $list.Update()
    }
    $rootWeb.Update()
    }
    

New-Object : Constructor not found. Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment. At line:9 char:33

  • $roleAssignment = New-Object <<<<  Microsoft.SharePoint.SPRoleAssignment( $group)
    
    • CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentExce ption
    • FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.C
      ommands.NewObjectCommand

Exception calling "Add" with "1" argument(s): "The permission level specified i s already added to the collection." At line:10 char:47

  • $RoleAssignment.RoleDefinitionBindings.Add <<<< ($role)
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression. At line:12 char:30

  • $list.RoleAssignments.Add <<<< ($roleAssignment)
    
    • CategoryInfo : InvalidOperation: (Add:String) [], RuntimeExcept ion
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At line:13 char:17

  • $list.Update <<<< ()
    
    • CategoryInfo : InvalidOperation: (Update:String) [], RuntimeExc eption
    • FullyQualifiedErrorId : InvokeMethodOnNull

"Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment" in PowerShell

I'm trying to add a SharePoint group to a specific list that exists on all the sites in a collection. I would think this would be easier but I'm having difficulties. Inheritance is already broken on the list. 

Below is my code and then the error I'm getting.

$siteNumbers = "2210"
$listsOnSite = "QWERTY"

Foreach($wnl in $siteNumbers)
    {
    $rootWeb = (Get-SPWeb ("http://url/to/site/" + $wnl))

    
    Foreach($lst in $listsOnSite)


    {
    $list = $rootWeb.Lists[$lst]
    $group = $rootWeb.Groups["Global Read-Only QWERTY"]
    $role = $rootWeb.RoleDefinitions["Read"]

    $roleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
    $RoleAssignment.RoleDefinitionBindings.Add($role)
    $rootWeb.RoleAssignments.Add($RoleAssignment)
    $list.RoleAssignments.Add($roleAssignment)
    $list.Update()
    }
    $rootWeb.Update()
    }
    

New-Object : Constructor not found. Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment. At line:9 char:33

  • $roleAssignment = New-Object <<<<  Microsoft.SharePoint.SPRoleAssignment( $group)
    
    • CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentExce ption
    • FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.C
      ommands.NewObjectCommand

Exception calling "Add" with "1" argument(s): "The permission level specified i s already added to the collection." At line:10 char:47

  • $RoleAssignment.RoleDefinitionBindings.Add <<<< ($role)
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression. At line:12 char:30

  • $list.RoleAssignments.Add <<<< ($roleAssignment)
    
    • CategoryInfo : InvalidOperation: (Add:String) [], RuntimeExcept ion
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At line:13 char:17

  • $list.Update <<<< ()
    
    • CategoryInfo : InvalidOperation: (Update:String) [], RuntimeExc eption
    • FullyQualifiedErrorId : InvokeMethodOnNull
added 106 characters in body
Source Link
NMJohns
  • 43
  • 1
  • 8

I'm trying to add a SharePoint group to a specific list that exists on all the sites in a collection. I would think this would be easier but I'm having difficulties. Inheritance is already broken on the list. Below is my code and then the error I'm getting. (This is not a duplicate question as the fix was different than what the suggested thread was solved by)

$siteNumbers = "2210"
$listsOnSite = "QWERTY"

Foreach($wnl in $siteNumbers)
    {
    $rootWeb = (Get-SPWeb ("http://url/to/site/" + $wnl))

    
    Foreach($lst in $listsOnSite)


    {
    $list = $rootWeb.Lists[$lst]
    $group = $rootWeb.Groups["Global Read-Only QWERTY"]
    $role = $rootWeb.RoleDefinitions["Read"]

    $roleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
    $RoleAssignment.RoleDefinitionBindings.Add($role)
    $rootWeb.RoleAssignments.Add($RoleAssignment)
    $list.RoleAssignments.Add($roleAssignment)
    $list.Update()
    }
    $rootWeb.Update()
    }
    

New-Object : Constructor not found. Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment. At line:9 char:33

  • $roleAssignment = New-Object <<<<  Microsoft.SharePoint.SPRoleAssignment( $group)
    
    • CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentExce ption
    • FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.C
      ommands.NewObjectCommand

Exception calling "Add" with "1" argument(s): "The permission level specified i s already added to the collection." At line:10 char:47

  • $RoleAssignment.RoleDefinitionBindings.Add <<<< ($role)
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression. At line:12 char:30

  • $list.RoleAssignments.Add <<<< ($roleAssignment)
    
    • CategoryInfo : InvalidOperation: (Add:String) [], RuntimeExcept ion
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At line:13 char:17

  • $list.Update <<<< ()
    
    • CategoryInfo : InvalidOperation: (Update:String) [], RuntimeExc eption
    • FullyQualifiedErrorId : InvokeMethodOnNull

I'm trying to add a SharePoint group to a specific list that exists on all the sites in a collection. I would think this would be easier but I'm having difficulties. Inheritance is already broken on the list. Below is my code and then the error I'm getting.

$siteNumbers = "2210"
$listsOnSite = "QWERTY"

Foreach($wnl in $siteNumbers)
    {
    $rootWeb = (Get-SPWeb ("http://url/to/site/" + $wnl))

    
    Foreach($lst in $listsOnSite)


    {
    $list = $rootWeb.Lists[$lst]
    $group = $rootWeb.Groups["Global Read-Only QWERTY"]
    $role = $rootWeb.RoleDefinitions["Read"]

    $roleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
    $RoleAssignment.RoleDefinitionBindings.Add($role)
    $rootWeb.RoleAssignments.Add($RoleAssignment)
    $list.RoleAssignments.Add($roleAssignment)
    $list.Update()
    }
    $rootWeb.Update()
    }
    

New-Object : Constructor not found. Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment. At line:9 char:33

  • $roleAssignment = New-Object <<<<  Microsoft.SharePoint.SPRoleAssignment( $group)
    
    • CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentExce ption
    • FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.C
      ommands.NewObjectCommand

Exception calling "Add" with "1" argument(s): "The permission level specified i s already added to the collection." At line:10 char:47

  • $RoleAssignment.RoleDefinitionBindings.Add <<<< ($role)
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression. At line:12 char:30

  • $list.RoleAssignments.Add <<<< ($roleAssignment)
    
    • CategoryInfo : InvalidOperation: (Add:String) [], RuntimeExcept ion
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At line:13 char:17

  • $list.Update <<<< ()
    
    • CategoryInfo : InvalidOperation: (Update:String) [], RuntimeExc eption
    • FullyQualifiedErrorId : InvokeMethodOnNull

I'm trying to add a SharePoint group to a specific list that exists on all the sites in a collection. I would think this would be easier but I'm having difficulties. Inheritance is already broken on the list. Below is my code and then the error I'm getting. (This is not a duplicate question as the fix was different than what the suggested thread was solved by)

$siteNumbers = "2210"
$listsOnSite = "QWERTY"

Foreach($wnl in $siteNumbers)
    {
    $rootWeb = (Get-SPWeb ("http://url/to/site/" + $wnl))

    
    Foreach($lst in $listsOnSite)


    {
    $list = $rootWeb.Lists[$lst]
    $group = $rootWeb.Groups["Global Read-Only QWERTY"]
    $role = $rootWeb.RoleDefinitions["Read"]

    $roleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
    $RoleAssignment.RoleDefinitionBindings.Add($role)
    $rootWeb.RoleAssignments.Add($RoleAssignment)
    $list.RoleAssignments.Add($roleAssignment)
    $list.Update()
    }
    $rootWeb.Update()
    }
    

New-Object : Constructor not found. Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment. At line:9 char:33

  • $roleAssignment = New-Object <<<<  Microsoft.SharePoint.SPRoleAssignment( $group)
    
    • CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentExce ption
    • FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.C
      ommands.NewObjectCommand

Exception calling "Add" with "1" argument(s): "The permission level specified i s already added to the collection." At line:10 char:47

  • $RoleAssignment.RoleDefinitionBindings.Add <<<< ($role)
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression. At line:12 char:30

  • $list.RoleAssignments.Add <<<< ($roleAssignment)
    
    • CategoryInfo : InvalidOperation: (Add:String) [], RuntimeExcept ion
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At line:13 char:17

  • $list.Update <<<< ()
    
    • CategoryInfo : InvalidOperation: (Update:String) [], RuntimeExc eption
    • FullyQualifiedErrorId : InvokeMethodOnNull
Source Link
NMJohns
  • 43
  • 1
  • 8

Powershell add SharePoint group to list

I'm trying to add a SharePoint group to a specific list that exists on all the sites in a collection. I would think this would be easier but I'm having difficulties. Inheritance is already broken on the list. Below is my code and then the error I'm getting.

$siteNumbers = "2210"
$listsOnSite = "QWERTY"

Foreach($wnl in $siteNumbers)
    {
    $rootWeb = (Get-SPWeb ("http://url/to/site/" + $wnl))

    
    Foreach($lst in $listsOnSite)


    {
    $list = $rootWeb.Lists[$lst]
    $group = $rootWeb.Groups["Global Read-Only QWERTY"]
    $role = $rootWeb.RoleDefinitions["Read"]

    $roleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
    $RoleAssignment.RoleDefinitionBindings.Add($role)
    $rootWeb.RoleAssignments.Add($RoleAssignment)
    $list.RoleAssignments.Add($roleAssignment)
    $list.Update()
    }
    $rootWeb.Update()
    }
    

New-Object : Constructor not found. Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment. At line:9 char:33

  • $roleAssignment = New-Object <<<<  Microsoft.SharePoint.SPRoleAssignment( $group)
    
    • CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentExce ption
    • FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.C
      ommands.NewObjectCommand

Exception calling "Add" with "1" argument(s): "The permission level specified i s already added to the collection." At line:10 char:47

  • $RoleAssignment.RoleDefinitionBindings.Add <<<< ($role)
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression. At line:12 char:30

  • $list.RoleAssignments.Add <<<< ($roleAssignment)
    
    • CategoryInfo : InvalidOperation: (Add:String) [], RuntimeExcept ion
    • FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression. At line:13 char:17

  • $list.Update <<<< ()
    
    • CategoryInfo : InvalidOperation: (Update:String) [], RuntimeExc eption
    • FullyQualifiedErrorId : InvokeMethodOnNull