1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| Function Set-DirACL
{
Param ($IUSRName, $Username, $Password, $ListRule, $Path, $ACLRule, $Description, $Directory)
If ((Test-Path -Path $Path) -ne $True)
{
New-Item $Path -Type Directory
}
If ($ACLRule -eq "ReadAndExecute")
{
$Account = New-Object System.Security.Principal.NtAccount("$IUSRName")
$ACL = Get-Acl -Path "$Path"
$Permission = "$Account","ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow"
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
$ACL.SetAccessRule($AccessRule)
$ACL | Set-Acl "$Path"
}
If ($ACLRule -eq "Modify")
{
$Account = New-Object System.Security.Principal.NtAccount("$IUSRName")
$ACL = Get-Acl -Path "$Path"
$Permission = "$Account","Modify","ContainerInherit,ObjectInherit","None","Allow"
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $Permission
$ACL.SetAccessRule($AccessRule)
$ACL | Set-Acl "$Path"
}
If ($ListRule -eq "ListFolders")
{
Set-WebConfigurationProperty System.WebServer/DirectoryBrowse IIS:\Sites\$Description\$Directory -Name Enabled -Value True
}
If ($ListRule -eq "NotListFolders")
{
Set-WebConfigurationProperty System.WebServer/DirectoryBrowse IIS:\Sites\$Description\$Directory -Name Enabled -Value False
}
} |