0

I found the following which seems to work for what it is, but I need 2 things changed, and can't figure it out.

$acl = Get-Acl D:\New
$permission = "Everyone","Read","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$acl | Set-Acl D:\New
  1. I need to be able to give "HomeGroup" permission, not "Everyone".
  2. I need this to recurse all folders.
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
RaveWolf
  • 11
  • 6

1 Answers1

0

When in doubt, read the documentation. You need to change the identity from "Everyone" to "$env:COMPUTERNAME\HomeGroup" and set the appropriate inheritance and propagation flags.

$identity    = "$env:COMPUTERNAME\HomeGroup"
$accessRight = 'Read'
$inheritance = 'ContainerInherit, ObjectInherit'
$propagation = 'None'
$type        = 'Allow'

$accessRule = New-Object Security.AccessControl.FileSystemAccessRule (
                $identity, $accessRight, $inheritance, $propagation, $type
              )
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • Thx, but it's not working. Getting... Exception calling "SetAccessRule" with "1" argument(s): "Some or all identity references could not be translated." – RaveWolf Mar 26 '16 at 00:00
  • Check the name of the group. Also try just the group name (without the hostname). – Ansgar Wiechers Mar 26 '16 at 11:48