让我们立即看一个应用示例:
在“公司共享文件库”的“公会”文件夹名称中添加“域\lixs”的“写保护”管理权限。
编码内容:
############################################ #Author:Lixiaosong #Email:lixs@ourgame.com;lixiaosong8706@gmail.com #For:设定SharePoint库文件夹名称安全性组管理权限 #Version:1.0 2015年3月26日 ############################################## function Add-SPPermiss="superseo">ssionToSeGroup { Param( [Parameter(Mandatory=$True,Position=1)] [string]$SPWeb, [Parameter(Mandatory=$True,Position=2)] [string]$SPList, [Parameter(Mandatory=$True,Position=3)] [string]$ADUser, [Parameter(Mandatory=$True,Position=4)] [string]$SPFolder, [Parameter(Mandatory=$True,Position=5)] [string]$SPPermission ) Add-PSSnapin Microsoft.SharePoint.PowerShell #http://glproject/PMO/doc $web = get-spweb "$SPWeb" function GrantUserpermission($userName) { [Microsoft.SharePoint.SPUserCollection]$spusers=[Microsoft.SharePoint.SPUserCollection]$web.SiteUsers [Microsoft.SharePoint.SPUser]$spuser=$spusers[$userName] $sproleass=new-object Microsoft.SharePoint.SPRoleAssignment([Microsoft.SharePoint.SPPrincipal]$spuser) $folder.BreakRoleInheritance("true") $sproleass.RoleDefinitionBindings.Add($web.RoleDefinitions["$SPPermission"]) $folder.RoleAssignments.Add($sproleass); Write-Host "Permission provided for user ", $userName } $doclib=[Microsoft.SharePoint.SPDocumentLibrary]$web.Lists["$SPlist"] $foldercoll=$doclib.Folders; foreach($folder in $foldercoll) { Write-Host $folder.Name if($folder.Name.Equals("$SPFolder")) { GrantUserPermission("Domain\$ADuser") } } Write-Host "Completed...." $web.Close() }欢迎分享,转载请注明来源:内存溢出
评论列表(0条)