Please help me about adding new AD users, AD groups with Permission to sharepoint site. I can do it for lists and document libararys but adding to site seems to be different. This is what i do for lists:
FunctionRights($user, $ShortListName, $permission){
$userName = $spweb.EnsureUser($User)
$spFolder = $spweb.lists[$ShortListName]if($spweb.SiteUsers[$userName]){
$assignment=new-objectMicrosoft.SharePoint.SPRoleAssignment($spweb.SiteUsers[$userName])
$assignment.RoleDefinitionBindings.Add($spweb.RoleDefinitions[$permission])
$spfolder.BreakRoleInheritance($false, $false)
$spfolder.RoleAssignments.add($assignment);Write-Host"Permission provided for group ", $userName
$spfolder.update()}else{Write-Host"group ""$userName"" was not found in this web!"}}If i simply change the spfolder spweb, it won't work
I Hate Mondays