Skip to main content

Printers

After each disk update, the system restores the original state and some configuration may be lost, you can automate the configuration of local printers, for network printers you can use domain policies or a scripted installation.

In this example, you rename a printer with a driver from Lexmark or HP adding an "I" to the computer's name, other configurations are set up such as sharing, or duplex printing by default. It would be launched in startup scripts or as a scheduled task when the computer boots.

$computer = gc env:computername
$printerName_laser = $computer + "I"
$printer_drivers_laser = @("Lexmark Universal", "HP")
foreach($printer_local in Get-Printer)
{
if (($printer_drivers_laser | %{$printer_local.DriverName -like "$_*"}) -contains $true)
{
Rename-Printer -Name $printer_local.Name -NewName $printerName_laser

Set-Printer -Name $printerName_laser -Shared $True -ShareName $printerName_laser -KeepPrintedJobs $False

#Force Driver to Auto Update items: duplexer, manual feed, tray 2...
Set-PrinterProperty -PrinterName $printerName_laser -PropertyName "Config:AutoAskPrinter" -Value OFF
Set-PrinterProperty -PrinterName $printerName_laser -PropertyName "Config:AutoAskPrinter" -Value ON
#Set default to print with duplex
Set-PrintConfiguration -printername $printerName_laser -DuplexingMode TwoSidedLongEdge
}
}