我有一个脚本,我认为可以让我的打印机以用户名格式输出其权限,我收到错误"找不到接受参数的位置参数"。权限SDDL'
下面是我的脚本
$computerfile = get-content "\testd$testLtesttestMW
scriptstest.txt"
ForEach ($computer in $computerfile) {
Get-WmiObject Win32_Printer -ComputerName $computer |
Select-Object Name,Systemname, Local |
Format-Table -AutoSize
}
$printers = Get-Printer Name -Full.PermissionSDDL
ForEach ($Printer in $Printers) {
$objSID = New-Object System.Security.Principal.SecurityIdentifier
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
$objUser.Value
}
发生这种情况,因为对象属性以不正确的方式引用。
这
$printers = Get-Printer Name -Full.PermissionSDDL
尝试传递 Get-Printer 不支持的参数-Full.PermissionSDDL
。更重要的是,-Name
开关缺少开关标识符和实际打印机名称。
正确的语法是
$printers = (Get-Printer -Name $myPrinter -Full).PermissionSDDL