我有一个脚本,将打印服务器上的所有打印机输出到文本文件中,然后查询该列表中的每台打印机以获取该打印机的权限,我在解决权限时遇到问题,以便它们被打印机分开命名和接收配额错误所以我想知道如何查询说出前250然后下一组以及输出数据以便权限在正确的打印机名称下面,下面是错误,脚本和我的列表看起来等。
function Convert-SDDLToACL {
[CmdletBinding()]
Param (
[string[]]$SDDLString
)
foreach ($SDDL in $SDDLString) {
$ACLObject = New-Object -Type Security.AccessControl.DirectorySecurity
$ACLObject.SetSecurityDescriptorSddlForm($SDDL)
$ACLObject.Access
}
}
# Creates Printer List
$computerfile = 'MPLSPS01'
foreach ($computer in $computerfile) {
Get-WmiObject Win32_Printer -ComputerName $computer |
Select-Object Name |
Out-File C:\Users\stephen.lyons.sa\Desktop\test\tes4.txt
}
# Gets print server list
$obj = Get-Content C:\Users\stephen.lyons.sa\Desktop\test\test4.txt |
Select-Object name
# Allows more than 100 printers to be queried
$ra = @(0..100)
# Returns ACE values into readable format
foreach ($object in $obj) {
$object
$sddl = (Get-Printer $obj -Full).PermissionSDDL
Convert-SDDLToACL $sddl |
Select-Object -Expand IdentityReference |
Select-Object -Expand Value
}