I have been adjusting an ACL in a script like so:
$Acl = get-acl -Path $File
$rule = New-Object -TypeName system.security.accesscontrol.filesystemaccessrule -ArgumentList ('Authenticated Users','Read','Allow')
$Acl.setaccessrule($rule)
set-acl -Path $File -AclObject $Acl
That has been working well on my English systems, but I am getting a report on a Dutch system: "Kan een aantal of alle id-verwijzingen niet omzetten" At the setaccessrule($rule)
.
The translation of that error ("Is possible a number or all id-references do not convert.") makes me think maybe the English-language Authenticated Users
doesn't exist on that machine and I need a language-neutral way of identifying that group.
Thanks.
I don't have a computer with a different language to test with but I believe the code below should work for you.
Essentially the issue is you'd want to use an IdentityReference
type to select AuthenticatedUserSid
rather than a String
representation when creating the FileSystemAccessRule
object. See here for the documentation.
$acl = Get-Acl -Path $File
$si = New-Object -TypeName 'System.Security.Principal.SecurityIdentifier' -ArgumentList @([System.Security.Principal.WellKnownSidType]::AuthenticatedUserSid, $null)
$rule = New-Object -TypeName 'System.Security.AccessControl.FileSystemAccessRule' -ArgumentList @($si, 'Read', 'Allow')
$acl.setaccessrule($rule)
Set-Acl -Path $File -AclObject $acl