How to create a folder in SharePoint2010 root folder and set permission to it
Posted
by ybbest
on YBBest
See other posts from YBBest
or by ybbest
Published on Wed, 14 Mar 2012 01:06:55 +0000
Indexed on
2012/03/18
18:26 UTC
Read the original article
Hit count: 377
If you need to create a folder in SharePoint2010 root folder and set permission to it, here is piece of code that does it. In the script, I have created a folder called Temp in Logs folder under SharePoint2010 root and then I grant read/write access to the Windows group WSS_WPG and full access to the group WSS_ADMIN_WPG for that folder.
$Folder=New-Item "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS\temp" -Type Directory -force $acl = Get-Acl $Folder ##The following line has been commented out , if you like to break the permission inheritance from the parent floder , uncommented the code. #$acl.SetAccessRuleProtection($True, $False) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("WSS_ADMIN_WPG","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("WSS_WPG","Modify", "ContainerInherit, ObjectInherit", "None", "Allow") $acl.AddAccessRule($rule) Set-Acl $Folder $acl
References:
http://technet.microsoft.com/en-us/library/ff730951.aspx
http://msdn.microsoft.com/en-us/library/tbsb79h3.aspx
http://chrisfederico.wordpress.com/2008/02/01/setting-acl-on-a-file-or-directory-in-powershell/
© YBBest or respective owner