0

I have a script that outputs all printers on a print server into a text file then queries each printer in that list to get the permissions on that printer, I am having an issue getting the permissions split so that they are separated by printer name and receiving a quota error so I am wondering how to query say the first 250 then the next set as well as outputting the data so that the permissions are under the proper printer name, below is the error, the script and what my list looks like.

enter image description here

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
}

Printer list

Slyons
  • 117
  • 4
  • 20
  • There is no `Test-Connection` in the code you posted. Also, just because you have a string `Name` at the beginning of a text file doesn't make `Get-Content` magically produce objects with a property `Name`. Collect the output of your WMI loop in a variable. Do not use a files as the transport medium between a command and a variable in the same script. Also, you may want to expand the property `Name`, and use `$object` instead of `$obj` with `Get-Printer`. – Ansgar Wiechers Jan 29 '18 at 22:07
  • uploaded the wrong picture, edited – Slyons Jan 29 '18 at 22:16
  • Please re-read my previous comment. *All* of it this time. – Ansgar Wiechers Jan 29 '18 at 22:40
  • Just uploading the correct image while I'm working on the script man – Slyons Jan 29 '18 at 23:49
  • That took care of both issues, thank you sir – Slyons Jan 30 '18 at 00:08

0 Answers0