IT tutorials
 
Technology
 

Windows Server 2012 : Managing print servers using Windows PowerShell (part 2) - Managing printers, printer drivers, and print jobs

5/19/2014 1:44:45 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Managing printers, printer drivers, and print jobs

You can use Windows PowerShell not only to view information about printers, printer drivers, and print jobs on remote print servers but also to manage printers, print drivers, and print jobs. The following sections demonstrate two examples of this, specifically:

  • Canceling a print job

  • Installing a network printer

Removing a print job

In an earlier section of this lesson, you saw that one of the print jobs for the HP LaserJet 5200 printer had Error for its status. To determine which job it is, you can pipe the output from the Get-PrintJob cmdlet into the Where-Object cmdlet to display all jobs whose JobStatus property has “Error” in its value:

PS C:\> Get-PrintJob -ComputerName HOST7 -PrinterName "HP LaserJet 5200 PCL6" | `
where JobStatus -like "Error*"

Id ComputerName PrinterName DocumentName SubmittedTime JobStatus
-- ------------ ----------- ------------ ------------- ---------
3 HOST7 HP LaserJet ... Document 3 8/26/2012 2:08:06 PM Error, Print...

Having determined that job #3 is the problem, you could now use the Remove-PrintJob cmdlet to cancel the problem job:

Remove-PrintJob -PrinterName "HP LaserJet 5200 PCL6" -ID 3

But instead of doing this, you can simply press the Up arrow to display the previously executed command and pipe its output into Remove-PrintJob as follows:

PS C:\> Get-PrintJob -ComputerName HOST7 -PrinterName "HP LaserJet 5200 PCL6" | `
where JobStatus -like "Error*" | Remove-PrintJob

Using the Get-PrintJob cmdlet again verifies that the problem has been resolved:

PS C:\> Get-PrintJob -ComputerName HOST7 -PrinterName "HP LaserJet 5200 PCL6"
Id ComputerName PrinterName DocumentName SubmittedTime JobStatus
-- ------------ ----------- ------------ ------------- ---------
4 HOST7 HP LaserJet ... Document 2 8/26/2012 2:08:06 PM Printing
5 HOST7 HP LaserJet ... Document 1 8/26/2012 2:08:06 PM Normal

Installing a network printer

Installing a new network printer using Windows PowerShell involves performing the following steps:

  1. Installing a printer driver for the new printer

  2. Creating a Standard TCP/IP Port for the printer

  3. Installing the printer using the driver and port specified

  4. Performing any additional configuration needed for the printer

For example, let’s say you want to install a printer that uses the Dell Color Laser PCL6 Class Driver on your print server. You could begin by using the Add-PrinterDriver cmdlet to install the printer driver on the server:

PS C:\> Add-PrinterDriver -ComputerName HOST7 -Name "Dell Color Laser PCL6 Class Driver"

You could use the Get-PrinterDriver cmdlet to verify the result as follows:

PS C:\> Get-PrinterDriver -ComputerName HOST7

Name PrinterEnvironment MajorVersion Manufacturer
---- ------------------ ------------ ------------
Dell Color Laser PCL6 Class Driver Windows x64 4 Dell
Samsung CLP-410 Series PCL6 Windows x64 4 Samsung
HP LaserJet 4200L PCL6 Class Driver Windows x64 4 HP
...

Next, you could use the Add-PrinterPort cmdlet to add a new port for the printer like this:

PS C:\> Add-PrinterPort -ComputerName HOST7 -Name "172.16.11.63" `
-PrinterHostAddress "172.16.11.63"

You could use the Get-PrinterPort cmdlet to verify the result:

PS C:\> Get-PrinterPort -ComputerName HOST7

Name ComputerName Description PortMonitor
---- ------------ ----------- -----------
172.16.11.55 HOST7 Standard TCP/IP Port TCPMON.DLL
172.16.11.63 HOST7 Standard TCP/IP Port TCPMON.DLL
COM1: HOST7 Local Port Local Monitor
...

Next, you could use the Add-Printer cmdlet to install, name, and share the new printer using the driver and port previously specified as follows:

PS C:\> Add-Printer -ComputerName HOST7 -Name "Sales Printer" `
-DriverName "Dell Color Laser PCL6 Class Driver" -Shared `
-ShareName "SalesPrint" -PortName "172.16.11.63"

The Get-Printer cmdlet could be used to verify the installation of the new network printer:

PS C:\> Get-Printer -ComputerName HOST7 | ft Name,DriverName,PortName

Name DriverName PortName
---- ---------- --------
Sales Printer Dell Color Laser PCL6 ... 172.16.11.63
HP LaserJet 5200 PCL6 HP LaserJet 5200 PCL6 ... 172.16.11.55
...

Finally, you might want to change the default paper size for the new printer from Letter to Legal like this:

PS C:\> Set-PrintConfiguration -ComputerName HOST7 -PrinterName "Sales Printer" `
-PaperSize Legal

You could then use the Get-PrintConfiguration cmdlet to verify the result:

PS C:\> Get-PrintConfiguration -ComputerName HOST7 -PrinterName "Sales Printer" | `
fl PaperSize

PaperSize : Legal
 
Others
 
- Windows Server 2012 : Managing print servers using Windows PowerShell (part 1) - Viewing information about printers, printer drivers, and print jobs
- Windows 8 : System Protection and Recovery - Advanced recovery and restoration options
- Windows 8 : System Protection and Recovery - Advanced settings and features for Windows recovery
- Sharepoint 2013 : Managing an Office 365 SharePoint Site - Create a New Public Site Collection
- Sharepoint 2013 : Managing an Office 365 SharePoint Site - Create a New Private Site Collection
- Sharepoint 2013 : Managing an Office 365 SharePoint Site - Sign In to Office 365 SharePoint Administrator Console
- Sharepoint 2013 : Authoring Pages - Discard the Check-out of a Page, Compare Versions of a Page
- Sharepoint 2013 : Authoring Pages - Publish a Page
- Sharepoint 2013 : Authoring Pages - Reuse a Web Part
- Sharepoint 2013 : Authoring Pages - Modify a Web Part
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us