Learn about Windows PowerShell
Summary: Explore and discover the additional Windows PowerShell modules in Windows 8.1.
Honorary Scripting Guy, Sean Kearney, is here this week. Today's post is the fourth in a series, and today we’re going to delve in the wonders of the Print Management module for Window PowerShell! You also might enjoy reading:
It might seem like a simple idea, but I prefer to keep as much to the console as possible. It makes any task I do easily repeatable—even something as simple as identifying printers, features, and drivers, or controlling print jobs, if needed.
For that purpose, Windows 8.1 comes complete with a built-in Print Management module for Windows PowerShell. Let’s crack open that baby and see the available cmdlets.
You can see there are more than enough cmdlets to meet our daily needs. The Get-Printer cmdlet by itself is already of interest to me. It (strangely enough!) "gets" me a list of printers:
But where it gets cool is how we can pull up additional information. If we combine it with the Get-PrintConfiguration, we can identify all of our printer features as objects:
Get-Printer | Get-PrintConfiguration
Provided we have local rights on the remote system, we can check on print jobs from Windows PowerShell directly:
Get-Printjob –Printername “Laserjet5” –computername “Contoso-FPS”
Or if you’re about to do maintenance on a remote printer, you can send a command via Windows PowerShell to suspend print jobs on one printer:
Get-Printer –name “Laserjet5” | Get-Printjob | Suspend-Printjob
Or perhaps you need to suspend all print jobs for all the printers? A minor change in the command:
Get-Printer | Get-Printjob | Suspend-Printjob
So now you’ve finished working on the printers, and you plug in their cables again. The staff has put away their torches and would like to get back to work. Let’s allow them to resume printing!
Get-Printer | Get-Printjob | Resume-Printjob
All of these are able to access computers remotely, so you could actually specify a list of print servers to pause for maintenance tasks.
Now here is an issue that used to drive me bananas…
After I updated printers to a newer model in the office, the central printers would maintain their names but have the newer drivers. I’d have to go about manually deleting the drivers on the servers! Not anymore!
Hello magical PowerShell Genie! I would like you to remove the driver for the now defunct LaserJet 1 printer:
Remove-Printerdriver “Laserjet 1”
Now here is a neat little task I ran across. You can use the same cmdlets to set up a rudimentary print share.
Let’s pick on my LaserJet 1 again. Let’s imagine I put it on the server and would like to share that printer as PRINTER01. With the Print Management module, I can use this simple line:
Set-Printer –name “Laserjet1” –Sharename “PRINTER01” –shared $TRUE
Or if you like, you could just as easily pick a better name, for example, “AccountingPrinter01”, and rename it:
Set-Printer –name “Laserjet 1” –Sharename “AccountingPrinter01” –shared $TRUE
All of this ability to manage printers so easily…
It makes me…*sniff, sniff*…miss managing printers!
Stop by tomorrow and we’ll dig around to see the last of my little nugget discoveries.
I invite you to follow The Scripting Guys on Twitter and Facebook. If you have any questions, send an email to The Scripting Guys at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then remember eat your cmdlets each and every day with a taste dash of creativity.
Sean Kearney, Windows PowerShell MVP and Honorary Scripting Guy