我的Powershell脚本出错了,我试图给出一个文件夹" Total Control"。我可以将Total Control赋予域/用户帐户,但我似乎无法使其适用于ComputerName \ Users帐户。这对于允许安装其他软件在我们组织中的各种计算机上工作非常重要(它们在“安全”选项卡中都有一个ComputerName \ Users帐户)。我想将Total Control赋予[ComputerName \ Users]帐户。
下面的屏幕显示了我的脚本可以创建的DomainUsers / Account,在它下面是ComputerName \ Account我无法以任何方式引用Total Control - 在本例中," Users(OHAIBMG00B7KP \ Users) )",触发错误。
此脚本用于为文件夹
创建帐户和总控制权限$directory = "C:\Program Files (x86)\CAREWare"
$domainName = "DHS"
$group = 'Domain Users'
$inherit = [system.security.accesscontrol.InheritanceFlags]"ContainerInherit, ObjectInherit"
$propagation = [system.security.accesscontrol.PropagationFlags]"None"
$acl = (Get-Item $directory).GetAccessControl("Access")
$user = "{0}\{1}" -f "$domainName", $group
$user.trim()
$access = "FullControl"
$accessType = "Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule -ArgumentList @("$user","$access", "$inherit", "$propagation", "$accessType")
$acl.SetAccessRule($accessRule)
set-acl $directory $acl
当我尝试将以下三行更改为引用ComputerName \ Users时,这是错误。
$directory = "C:\Program Files (x86)\CAREWare"
$domainName = $env:computername
$group = 'Users'
Exception calling "SetAccessRule" with "1" argument(s): "Some or all identity references could not be translated."
At line:1 char:1
+ $acl.SetAccessRule($accessRule)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IdentityNotMappedException
我似乎无法让PowerShell查找并返回有关ComputerName \ Users组的任何内容,但它位于“文件夹属性”的“安全”选项卡中。