1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| Function Set-ReadOnlyFTP
{
Param ($FTPUsername, $ACLRule, $Path)
If ($ACLRule -eq "ReadOnly")
{
$Account = New-Object System.Security.Principal.NtAccount("$FTPUsername")
$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("$FTPUsername")
$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"
}
} |