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

Where 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

Executing this PowerShell query for a specific printer 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.

3
  • 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. Commented Sep 1, 2023 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
    Commented Sep 2, 2023 at 0:03
  • 1
    See superuser.com/questions/1773081/… 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. Commented Sep 3, 2023 at 3:19

1 Answer 1

0

To retrieve a printer's Printing Defaults configuration settings with PowerShell, you can utilize the Get-PrintConfiguration cmdlet. This approach is compatible with both Windows 10 and Windows Server 2019, as confirmed.

Note: All printer's this confirmed to work were using manufacturer "Universal" classified drivers.

PowerShell

$p = "Printer XYZ";
$printerConfigs = Get-PrintConfiguration -PrinterName $p;
$printerConfigs | Select PrinterName, Collate, Color, DuplexingMode, PaperSize;

Output

PrinterName   : Printer XYZ
Collate       : False
Color         : True
DuplexingMode : TwoSidedLongEdge
PaperSize     : Letter

Supporting Resources


Complimentary

  • The DEVMODEW Structure

  • What is DEVMODE?

    DEVMODE is a Windows structure that holds printer settings (initialization and environment information about a printer). It contains two parts: public and private.

    • Public part contains data that is common to all printers.

    • Private part contains data that is specific to a particular printer. Private part can be of variable length and contains all specific manufacturer related settings.

      • Public part: This part encodes general settings that are exposed in the printer driver model, such as printer name, driver version, paper size, orientation, color, duplex, and similar. Public part remains unchanged any printer driver and does not support specifics related to label printers (thermal printers, industrial ink jet printers, laser engraving machines).

      • Private part: This part encodes settings that are not available in the public part. <Some manufacturer> printer drivers use this part to store the printer model-specific data, such as printing speed, temperature setting, offsets, print mode, media type, sensors, cutters, graphics encoding, RFID support, and similar. Data structure within the private part of DEVMODE is a stream of binary data defined by driver developers.

    DEVMODE Changing

    DEVMODE data structure is stored in Windows registry. There are two copies of the structure: default printer settings and user-specific printer settings. You can alter the DEVMODE (printer settings) by changing the parameters in the printer driver. The first two options are Windows related, while the third option is available with <some manufacturer> software.

    • Default printer settings: These settings are defined in Printer properties > Advanced tab > Printing Defaults.

    • User specific settings: These settings are stored separately for each user in the user's HKEY_CURRENT_USER registry key. By default, user specific settings are inherited from the printer’s default settings. The user specific settings are defined in Printer properties > Preferences. All modifications here only affect the current user.

    Source

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .