我一直在像这样的脚本中调整 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)
。
该错误的翻译(“可能是一个数字或所有 id 引用都无法转换。”)让我觉得该机器上可能不存在英语Authenticated Users
,并且我需要一种与语言无关的方式来识别该组。
- 内置群组是否特定于语言?
- 我怎样才能以与语言无关的方式做同样的事情?
谢谢。
最佳答案
我没有可以使用其他语言进行测试的计算机,但我相信下面的代码应该适合您。
本质上,问题是您在创建 时希望使用
对象。 See here for the documentation. IdentityReference
类型来选择 AuthenticatedUserSid
而不是 String
表示形式>FileSystemAccessRule
$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
关于windows - 语言中立的文件系统访问规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54222763/