1
+ Write-Host ' creating kptnhook directories @ C:\kptnhook if not exists'
2
+ md - Force ' C:\kptnhook'
3
+ md - Force ' C:\kptnhook\Ship'
4
+ md - Force ' C:\kptnhook\Data'
5
+
6
+ function allow-dir {
7
+ param ([string ]$path , [string ]$ident )
8
+
9
+ # $user = [Security.Principal.NTAccount]::new($ident).Translate([System.Security.Principal.SecurityIdentifier])
10
+ $user = [Security.Principal.NTAccount ]::new(" ALL RESTRICTED APPLICATION PACKAGES" ).Translate([System.Security.Principal.SecurityIdentifier ])
11
+ Write-Host $user
12
+ $rule = [Security.AccessControl.FileSystemAccessRule ]::new($user , " ReadAndExecute" , " Allow" )
13
+ $acl = Get-Acl $path
14
+ $acl.SetAccessRule ($rule )
15
+ Set-Acl - Path $path - AclObject $acl
16
+ }
17
+
18
+ foreach ($path in Get-ChildItem ' C:\kptnhook' ) {
19
+ allow- dir $path ' ALL RESTRICTED APPLICATION PACKAGES'
20
+ # allow-dir $path 'EVERYONE'
21
+ }
22
+
23
+ $NewAcl = Get-Acl - Path ' C:\kptnhook'
24
+ # Set properties
25
+ $identity = " BUILTIN\Everyone"
26
+ $fileSystemRights = " Read"
27
+ $type = " Allow"
28
+ # Create new rule
29
+ $fileSystemAccessRuleArgumentList = $identity , $fileSystemRights , $type
30
+ $fileSystemAccessRule = New-Object - TypeName System.Security.AccessControl.FileSystemAccessRule - ArgumentList $fileSystemAccessRuleArgumentList
31
+ # Apply new rule
32
+ $NewAcl.SetAccessRule ($fileSystemAccessRule )
33
+ Set-Acl - Path ' C:\kptnhook' - AclObject $NewAcl
0 commit comments