Constructor Not Found


  • Script works individually ran but when added to a bigger script it fails. Trying to figure this out. Can someone help?

    New Object A constructor was not found. Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment


    Function AddGroupToSite ($web, $groupName, $permLevel) {

                    Write-Output “Adding $($groupName)…”

                    $account =  $Null

                    Foreach($grp in $web.Groups) {

                                    Write-Output “$account.Name”

                    If($grp -eq $groupName) {

                                    $account = $groupName

                                    Write-Output “Group found: $($”;

                                    Write-Output “In the if statement”




                    $assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($account)

                    $role = $web.RoleDefinitions[$permLevel]



                    Write-Output “Completed Group Permissions Level Assignments”


    Lewin Wanzer MCSE, MCDBA, MCTS (SQL 2005, 2010 Config, 2007 Config)

    Friday, April 21, 2017 3:07 AM

All replies

  • $account is not a string.  It must be an SPPrincipal.  You are using a string.


    Friday, April 21, 2017 4:44 AM