Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

PowerShell \ Add Group to Sites Permissions

$
0
0

$web=Get-SPWeb "https://portal/PWA/Subweb"
$group=$web.SiteGroups["Groupname"] 
$roleAssignment=New-Object Microsoft.SharePoint.SPRoleAssignment($group) 
$roleDefinition=$web.RoleDefinitions["Read"]
$roleAssignment.RoleDefinitionBindings.Add($roleDefinition) 
$web.RoleAssignments.Add($roleAssignment); 

Here it fails with an error:

Exception calling "Add" with "1" argument(s): "Object reference not set to an instance of an object."

Why? Groupname and Securitylevel checked

$web.Update() 
$web.Dispose() 


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>