Apply the Permissions
- Last UpdatedAug 27, 2024
- 1 minute read
Open a PowerShell window as administrator, and then run the following commands to apply the permissions to the folder, using the values for each of the 4 configurations shown in the previous section:
$existingAcl = Get-Acl -Path $folderPath
$permissions = $group, $access, 'ContainerInherit,ObjectInherit', 'None', 'Allow'
$rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $permissions
$existingAcl.SetAccessRule($rule)
$existingAcl | Set-Acl -Path $folderPath
(Get-ACL -Path $folderPath).Access | Format-Table IdentityReference,FileSystemRights,AccessControlType,IsInherited,InheritanceFlags -AutoSize
The last command above will print out a table showing the permissions that the groups have been given on the folder. Verify that the group defined in $group now has the access that was applied to the folders.