我正在使用PowerShell脚本来更改“内置用户”组的权限,基本上,我需要将“修改”添加到一个文件夹中。我需要对约400个系统执行此操作。我的计算机名称未显示。
$computer = Get-Content -Path c:\computernames.txt
$user = "BUILTIN\Users"
$Rights = "Modify","Synchronize"
$InheritSettings = "Containerinherit, ObjectInherit"
$PropogationSettings = "None"
$RuleType = "Allow"
foreach ($computer in $computernames) {
$path = "\\$computer\C$\Program Files (x86)\Directory1\Directory2"
$acl = Get-Acl $path
$perm = $user, $Rights, $InheritSettings, $PropogationSettings, $RuleType
$rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $perm
$acl.SetAccessRule($rule)
$acl | Set-Acl -Path $path
}
我希望代码能在一个文本文件中贯穿所有400个名称并更改权限。