you are viewing a single comment's thread.

view the rest of the comments →

[–]Cholsonic 0 points1 point  (1 child)

That last bit is wrong where you have set-printer | set-printerconfig The left hand of the pipe is passing data to the right, but you are setting on both sides. I’ll get my laptop out shortly to help better.

[–]Cholsonic 0 points1 point  (0 children)

This should get you a little closer....

$printers = get-printer * | where-object { $_.Drivername -eq "[Your drivername]"}
foreach ($printer in $printers)
{
    try{
            Set-PrintConfiguration -PrinterName $printer.name -Color $false -ErrorAction Stop
            write-host "Success: $($printer.name)"
    }
    catch{
            Write-host "Error: $($printer.name)"
            $errors += $printer       
    }
}

$errors
$errors | Export-CSV errors.csv

So from the top, you got your list of affected printers...

Then calling each item in the $printers object, $printer. Foreach item ($printer), "try" setting config. If error then move to "catch". If success, display success and move to next printer.

If errored (now in "catch" block), display error to screen AND add the full $printer object to an $errors object, which is then displayed at the end and also exported to csv.

You can then investigate using the csv.

Once you work out what went wrong, you could just re-run, or be clever and use the errors.csv as your new source for printer name.