标签:权限 文件夹 sharepoint
我们直接拿一个应用举例:
为“部门共享文档库”里面的“工会”文件夹添加“domain\lixs”的“只读”权限。
代码内容:
############################################ #Author:Lixiaosong #Email:lixs@ourgame.com;lixiaosong8706@gmail.com #For:设置SharePoint库文件夹安全组权限 #Version:1.0 2015年3月26日 ############################################## function Add-SPPermissionToSeGroup { 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() }
本文出自 “运维人生” 博客,请务必保留此出处http://lixiaosong.blog.51cto.com/705126/1627346
设置SharePoint站点库文件夹安全组或AD用户权限脚本
标签:权限 文件夹 sharepoint
原文地址:http://lixiaosong.blog.51cto.com/705126/1627346