To set the SharePoint Site Library folder security Group or AD user Rights script

Source: Internet
Author: User

We take an example of an application directly:

Add the "read-only" permission for "Domain\lixs" to the "Trade unions" folder in the departmental Shared Documents library.

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m00/5c/24/wkiol1ubpnbzn_jaaaevmhx8mzw420.jpg "height=" 359 "/>

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m00/5c/24/wkiol1ubpnmckbjbaagtsyuwij0464.jpg "height=" 378 "/>

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/5c/29/wkiom1ubptyrcwb-aaet9wbsfn0672.jpg "height=" 364 "/>


Code content:

############################################ #Author:lixiaosong#email:[email protected]; [email protected] #For: Set permissions for SharePoint library folders Security group #version:1.0 2015 March 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] $web $spusers =[microsoft.sharepoint.spusercollection]. 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 ()}


This article is from the "operation and maintenance of life" blog, please make sure to keep this source http://lixiaosong.blog.51cto.com/705126/1627346

To set the SharePoint Site Library folder security Group or AD user Rights script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.