Reputation: 14695
We're creating a script that collects user input from an Excel file. Each row represents one printer with its specific settings. So for each row we need to create a print queue on the print server.
We're struggling with setting the default settings for the printer So that when a user on the network adds the printer to his/her system, the settings are taken over from the queue on the print server.
Example with PageOrientation
On the print queue on the server we select Properties > Preferences > Basic
where we set PageOrientation = Landscape
. These settings are used when a user installs the network printer on his/her system:
Within PowerShell we tried to request the value for PageOrientation
and expect to find Landscape
but always get Portrait
.
Some code:
Add-Type -AssemblyName System.Printing
$permissions = [System.Printing.PrintSystemDesiredAccess]::AdministrateServer
$queueperms = [System.Printing.PrintSystemDesiredAccess]::AdministratePrinter
$server = New-Object System.Printing.PrintServer -argumentList $permissions
$queues = @($server.GetPrintQueues())
$Printer = $queues.Where( {$_.Name -eq $testPrinter.PrinterName})
# Results all in 'Portrait' not 'Landscape'
$Printer.CurrentJobSettings.CurrentPrintTicket.PageOrientation
$Printer.DefaultPrintTicket.PageOrientation
$Printer.PropertiesCollection.UserPrintTicket.value.PageOrientation
$Printer.PropertiesCollection.DefaultPrintTicket.value.PageOrientation
$Printer.UserPrintTicket.PageOrientation
Trying to use Set-PrintConfiguration
for changing the default tray does reflect a change when checked with Get-PrinterConfiguration
, but it's not visible in the GUI and also not applied as a default when a user adds the network printer.
$PrintConfiguration = Get-PrintConfiguration -PrinterName $PrinterName
$PrintTicketXML = [XML]$PrintConfiguration.PrintTicketXML
$CurrentTray = ($PrintTicketXML.PrintTicket.Feature).where( {$_.name -eq 'psk:JobInputBin'}).option.name
$NewTray = if ($Tray -eq 'AutoSelect') {"psk:$Tray"} else {"ns0000:$Tray"}
$UpdatedPrintTicketXML = $PrintConfiguration.PrintTicketXML -Replace "$CurrentTray", "$NewTray"
Set-PrintConfiguration -PrinterName $PrinterName -PrintTicketXml $UpdatedPrintTicketXML
Where can we find these default properties like Default tray
, Paper type
, ... and most importantly set their values?
Upvotes: 1
Views: 1604