Zend certified PHP/Magento developer

Obtain ‘Printing Defaults’ settings from a Printer’s ‘Properties’

I need a solution to programmatically query and output the specified property values as defined on a printer’s Printing Defaults settings.

I’m able to get the property values of these settings set in printer’s Preferences with PowerShell no problem, but I cannot get the settings set within the “Printing Defaults” in particular.

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 running this PowerShell query against a specific printer, it returns the specific settings from the Preferences only and not the Printing Defaults which is what I really need.

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

This screen shot is what I see in the preferences option of this printer and the PowerShell query output shows me this as expected. In the printing defaults, it is set to color and two-sided and set differently that 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 and run 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 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.