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
:
- Printing Preferences:
Printer Properties
|General
tab |Preferences
- 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
This is what I see in Printing Defaults
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.