Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignm ent

I am trying to use PowerShell to update the permission of groups in my sites, and I am using this script.

$ver = $host | select version
if($Ver.version.major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
if(!(Get-PSSnapin Microsoft.SharePoint.PowerShell -ea 0))
{
Write-Progress -Activity "Loading Modules" -Status "Loading Microsoft.SharePoint.PowerShell"
Add-PSSnapin Microsoft.SharePoint.PowerShell
}

$web = Get-SPWeb http://theSite
$group = $web.Groups["GroupOne Members"]
$role = $web.RoleDefinitions["Read"]

$RoleAssignment = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
$RoleAssignment.RoleDefinitionBindings.Add($role)

$web.RoleAssignments.Add($RoleAssignment)
$web.Update()
$web.Dispose()

When I ran my script the first time and it worked just fine, however I am not getting the "Aconstructor was not found. Cannot find an appropriate constructor for type Microsoft.SharePoint.SPRoleAssignment." error when I run the same script for subsequent sites. I don't understand why it worked the first time, but won't work now...anyone ever run into this? 

March 18th, 2015 3:46pm

did you confirm that $group is not null?
Free Windows Admin Tool Kit Click here and download it now
March 18th, 2015 5:23pm

Thanks for the reply Scott Brickey...you are right, $group is now null, even though the group does exists in SP. Any ideas on what might be causing this, and how to rectify this?
March 18th, 2015 6:51pm

Type $Web.groups and press enter. Review the names displayed to see if the name is what you think it is.

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2015 7:22pm

Hi,

Any update?

Best regards

March 29th, 2015 9:30pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics