Recently I ran into a need to change the printer location on over a thousand print queues in an enterprise environments. Apparently the printer’s location is used along side an active directory site location to make that search for network printers feature in windows work.
As you can imagine, right-clicking and manually entering the location would probably get pretty old pretty fast and would take a while too. So I turned to powershell and created a pair of functions to assist in completing this task. I present Get-PrinterLocation and Set-PrinterLocation! *Fanfare*
K, so maybe it’s a pretty niche thing, but I really hope it helps someone out there! So, basically here’s how you use it.
Say you need to set the print queue locations on a print server called printserv1 to Seattle, WA. The command would look something like this:
Set-PrinterLocation -Server printserv1 -Location "Seattle, WA"
Just like that, all of the print queue names on the server have been changed. The function also has a -printer parameter that accepts wildcard input based on the printer sharename in case you need to scope down the which queues you want to change.
Then, if you need to check your work, simply use Get-PrinterLocation. -Server printserv1 to check the location names.
Below is the code I’ve written for this purpose. If you have an existing PowerShell module library with functions for your help desk or junior admins, this might be a good addition to those modules.
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.
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.