语言中性文件系统访问规则
language neutral FileSystemAccessRule
我一直在像这样调整脚本中的 ACL:
$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
这在我的英语系统上运行良好,但我在荷兰语系统上收到一份报告:"Kan een aantal of alle id-verwijzingen niet omzetten" 在 setaccessrule($rule)
。
该错误的翻译 ("Is possible a number or all id-references do not convert.") 让我觉得可能英语语言 Authenticated Users
在该机器上不存在,我需要一种语言中立的方式来识别该组。
- 内置群组是否特定于语言?
- 我怎样才能以语言中立的方式做同样的事情?
谢谢。
我没有可以使用不同语言进行测试的计算机,但我相信下面的代码应该适合你。
本质上,问题是您希望在创建 FileSystemAccessRule
时使用 IdentityReference
类型到 select AuthenticatedUserSid
而不是 String
表示目的。 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
我一直在像这样调整脚本中的 ACL:
$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
这在我的英语系统上运行良好,但我在荷兰语系统上收到一份报告:"Kan een aantal of alle id-verwijzingen niet omzetten" 在 setaccessrule($rule)
。
该错误的翻译 ("Is possible a number or all id-references do not convert.") 让我觉得可能英语语言 Authenticated Users
在该机器上不存在,我需要一种语言中立的方式来识别该组。
- 内置群组是否特定于语言?
- 我怎样才能以语言中立的方式做同样的事情?
谢谢。
我没有可以使用不同语言进行测试的计算机,但我相信下面的代码应该适合你。
本质上,问题是您希望在创建 FileSystemAccessRule
时使用 IdentityReference
类型到 select AuthenticatedUserSid
而不是 String
表示目的。 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