0

How can I programmatically retrieve and display property values from a printer's Printing Defaults settings?

I can successfully retrieve property values from a printer's Preferences using PowerShell, but I'm encountering difficulties when trying to access settings specifically within Printing Defaults.

More Context

So you can set a printer's preferences and you can set a printers printing defaults:

  1. Printing Preferences: Printer Properties | General tab | Preferences
  2. Printing Defaults: Printer Properties | Advanced tab | Printing Defaults

When executing this PowerShell query for a specific printer, it only retrieves settings from the Preferences and not the Printing Defaults, which is the information I require..

Get Printing Defaults

$p = "Printer XYZ";
$printerConfigs = Get-WmiObject -Class Win32_PrinterConfiguration | Where {$_.Name -like "*$p*"};

foreach ($config in $printerConfigs) {
    $printerName = $config.Caption;
    $collate = $config.Collate;
    $color = $config.Color;
    $duplex = $config.Duplex;
    $paperSize = $config.PaperSize;

    ## -- Display output
    Write-Host "Printer: $printerName" -ForegroundColor Yellow;
    Write-Host "Collate: $collate" -ForegroundColor Yellow;
    Write-Host "Color: $color" -ForegroundColor Yellow;
    Write-Host "Duplex: $duplex" -ForegroundColor Yellow;
    Write-Host "Paper Size: $paperSize" -ForegroundColor Yellow;
    
    Write-Host "-----------------------";
};

Printer settings

Using driver: RICOH PCL6 Universal V4.37

Included is a screen shot of what I see in the preferences options of this printer, and the PowerShell query output shows me this as expected. However, in the printing defaults, it is set to color and two-sided, set differently than the preferences.

If I change the preferences and then run the PowerShell query, I can see the output values change as expected—I cannot see the printing defaults and those values when they change (or are different) when rerunning this query. I'm interesting in seeing the printing default setting values.

This is what I see in Preferences

enter image description here

This is what I see in Printing Defaults

enter image description here

Output

Printer: Printer XYZ
Collate: False
Color: 1
Duplex: False
Paper Size: Letter 8 1/2 x 11 in
-----------------------

I have also tried using Get-WmiObject -Class Win32_Printer and a slew of other things, but I've not gotten back the settings from the Printing Defaults as are set on the printer.

In conclusion, I look forward to receiving guidance, advice, sample code, or any experiences you've had in successfully retrieving these printer properties. Additionally, if you have non-PowerShell solutions that can help me achieve this goal, I'm open to exploring those options as well. My primary focus is on obtaining the necessary property values from the printers.

Vomit IT - Chunky Mess Style
  • 40,038
  • 27
  • 84
  • 117
  • 2
    Note that you are not querying the printer, but the printer driver, for this data. – music2myear Sep 01 '23 at 19:42
  • I can't quite follow the question. you have a subhead "Get Printing Defaults" for code and clear output but you also say you cannot get the printing defaults? Also, you have highlighted something in red in your screencap which one might take to be the information you want, which appears to be in the output. (i.e. B&W is one color mode; 2-sided off is duplex false) – Yorik Sep 01 '23 at 20:54
  • 1
    So please forgive me @VomitIT-ChunkyMessStyle as it has been a while since I wrote drivers but if memory serves.. these are stored on the local machine at a driver level. I seem to remember default, current, and per application being stored differently in the registry. You might try figuring out where the keys are and querying/poking them directly or using c++ win32. The .net wrapper sucks and that part is not a guess. I had to write my own p/invoke wrappers around it because of how hard it blew. – Señor CMasMas Sep 01 '23 at 21:45
  • As you are querying the driver, I guess you would only see the current settings - i.e. Printing Preferences, not Printing Defaults. – hdhondt Sep 02 '23 at 00:03
  • See https://superuser.com/questions/1773081/where-are-windows-printers-preferences-saved for how default printer are stored in the *Registry*. Though for some these are hex values, not human readable, you could export keys with different options in place, if you wanted to set print quality or paper size, for example. – DrMoishe Pippik Sep 03 '23 at 03:19

0 Answers0