search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Setting ACL of Web Site directories with a Function on Powershell
Posted in Hosting & IIS7, Windows Powershell, Windows Server | No Comment | 3,967 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”.



Leave a Reply