Printers just seems to be one of those things I keep coming back to. Seems like SysAdmins always have several different scenarios for deploying printers. I’m hoping this new addition to the ServerAdminCommon helps solve the following problem:

Ever need printers installed for all users on a workstation, but can’t to use GPO to configure them?

In past times we used to use rundll32,printui.dll,printuientry to do that (or 3rd party software). While it’s possible to get your way through printui via command line or VB, I think it’s time we had a PowerShell update to this older method. So, I created 3 PowerShell functions to manage globally installed printers.

I present Get-GlobalPrinter, Add-GlobalPrinter, and Remove-GlobalPrinters.

Add-GlobalPrinter

Lets start with Add-GlobalPrinter. Usage:

Add-GlobalPrinter -UNC "\\win2k16-file01\Test-Printer01"

Add-GlobalPrinter

Then just like that, printer is installed for all users on the workstation. The command can also be used on remote computers by simply adding the -computername argument. Example:

Add-GlobalPrinter -Computername "Win10-PC01" -UNC "\\win2k16-file01\Test-Printer01"

Get-GlobalPrinter

Next, lets verify the global printer has been installed. We can do this using Get-GlobalPrinter. Usage:

Get-GlobalPrinter

Get-GlobalPrinter

Just like Add-GlobalPrinter, you can specify a remote computer using the -computername parameter to check what’s currently installed.

Usage:

Get-GlobalPrinter -Computername "Win10-PC01"

Remove-GlobalPrinter

Finally, we’ll deal with removing global printer. Usage:

Remove-GlobalPrinter -UNC "\\win2k16-file01\Test-Printer01"

Or… get the printers using Get-GlobalPrinter and pipe to Remove-GlobalPrinter

Get-GlobalPrinter -Printer "Test-Printer01" | Remove-GlobalPrinter

Remove-GlobalPrinterCombo

aaand… it’s gone. Simple as that. Just like the last 2 functions, this command can be run remotely by specifying the -computername argument.

Another thing I want to point out is that all of the functions above will accept array input for both computer names and UNC Paths. One more fun pipeline combo is with a previous tool on this blog, Get-ADPrinter.

Get-AdPrinter -Printer Test-Printer01 | Add-GlobalPrinter -ComputerName Localhost

Get-ADPrinterCombo

The tools being developed on this blog are available on the PowerShell gallery here! This means to begin using the tool set, simply run the following command to install them.


Install-Module -Name ServerAdminCommon

If you have previously installed the toolset, you can update the tools using following command:


Update-Module -Name ServerAdminCommon

As with all of the modules on this blog, you can find this tool on my github page for the ServerAdminCommon tool set.

Enjoy!

Disclaimer: All scripts and other powershell references on this blog are offered “as is” with no warranty. While these scripts are tested and working in my environment, it is recommended that you test these scripts in a test environment before using in your production environment.