Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

update object System.Printing.PrintQueue

I need to update an attribute in a printer driver. I’m able to get the right information but i don’t know how to change this value.

Add-Type -AssemblyName System.Printing

$adminServer = [System.Printing.PrintSystemDesiredAccess]::AdministrateServer
$adminPrinter = [System.Printing.PrintSystemDesiredAccess]::AdministratePrinter

$server = new-object System.Printing.LocalPrintServer $adminServer

$queues = $server.GetPrintQueues()

foreach($q in $queues){
$objPrinter = new-object System.Printing.PrintQueue -argumentList $server,$q.Name,$adminPrinter
$objPrinter.CurrentJobSettings.CurrentPrintTicket.PageMediaType
}

The output of $objPrinter.CurrentJobSettings.CurrentPrintTicket.PageMediaType is Unknown and should be changed to AutoSelect

Can someone help me? 🙂

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It’s been a while since I worked with Printer Management on Windows, but I’m fairly certain you want to update the DefaultPrintTicket rather than whatever settings are associated with the current job, so set it like this instead:

$objPrinter.DefaultPrintTicket.PageMediaType = 'AutoSelect'

… and then persist the configuration changes in the print server with PrintQueue.Commit():

$objPrinter.Commit()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading