Categories
Archive
![]() Blogroll
|
Setting ACL of Web Site directories with a Function on Powershell
Posted in Hosting & IIS7, Windows Powershell, Windows Server | No Comment | 1,408 views | 27/02/2010 16:01
After creating web site directories, you should set ACL settings of directories. Function Set-IISACL { Param ($Username, $LogDir) $Netbios = "FABRIKAM" $Account = New-Object System.Security.Principal.Ntaccount("$Netbios\$Username") $ACL = Get-Acl -Path "$LogDir" $ACL.SetAccessRuleProtection($True, $True) Set-Acl -Path "$LogDir" -AclObject $ACL $Permission = "$Account","ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow" $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission $ACL.SetAccessRule($AccessRule) $ACL | Set-Acl "$LogDir" $Permission = "$Account","Modify","ContainerInherit,ObjectInherit","None","Allow" $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission $ACL.SetAccessRule($AccessRule) $ACL | Set-Acl "$LogDir\db" $Permission = "$Account","Modify","ContainerInherit,ObjectInherit","None","Allow" $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission $ACL.SetAccessRule($AccessRule) $ACL | Set-Acl "$LogDir\http\upload" } Fabrikam is my Netbios name. If you create your users on Active Directory, you should write your Netbios name of your domain. But on a local machine, you can use your local computer name like “Plesk01\username”.
Tags: iis7.5 acl settings powershell, iis7.5 directory acl powershell, set-iisacl, setting acl with function on powershell, setting iis7 acl
Leave a Reply
|