en-US/about_spec.printer.management.help.txt

TOPIC
    about_spec.printer.management
 
SHORT DESCRIPTION
A module for managing printers, drivers, and ports using an object-oriented approach in PowerShell.
 
LONG DESCRIPTION
The spec.printer.management PowerShell module provides a comprehensive, object-oriented solution for managing printers, drivers, and ports within an environment. It introduces a `Printer` class, allowing users to create printer objects that can perform various tasks related to printer setup and maintenance, such as adding or removing printers, verifying the existence of drivers and ports, and automating configurations.
 
With the `spec.printer.management` module, administrators can streamline their printer management processes, reducing the complexity of multi-step configurations. The module is designed to work in a variety of networked environments, supporting both local and network printers. By leveraging functions such as `New-specPrinterObject`, users can easily initialise and interact with printer objects to install, manage, or remove printers and their associated components, ensuring flexibility and control over their printer infrastructure.
 
 
 
EXAMPLES
# spec.printer.management
 
## Overview
 
The `spec.printer.management` PowerShell module provides a streamlined, object-oriented approach for managing printers, drivers, and ports within your environment. It includes a `Printer` class that simplifies tasks such as adding, removing, and verifying the existence of printers, drivers, and ports.
 
By using the `New-specPrinterObject` function, you can create printer objects to efficiently manage printer configurations and automate complex setups.
 
---
 
## Getting Started
 
### Installation
 
To install the module from the PowerShell Gallery, run the following command:
 
    Install-Module -Name spec.printer.management
 
After installation, import the module into your session:
 
    Import-Module spec.printer.management
 
### Creating a Printer Object
 
To create a printer object, use the `New-specPrinterObject` function. This function initialises and returns an instance of the `Printer` class, which can be used to manage printers, drivers, and ports.
 
#### Example Usage
 
    # Create a new Printer object
    $printer = New-specPrinterObject -Name 'OfficePrinter' -Driver 'HP LaserJet' -PortName 'OfficePort' -PrinterHostAddress '192.168.1.10'
 
    # Add the printer to the system
    $printer.AddPrinter()
 
    # Check if the printer driver exists
    $exists = $printer.DriverExists()
    Write-Host "Driver exists: $exists"
 
    # Install the full printer setup (driver, port, and printer)
    $printer.InstallPrinter()
 
---
 
## Function: `New-specPrinterObject`
 
The `New-specPrinterObject` function creates and returns an instance of the `Printer` class. It accepts parameters for the printer name, driver, port name, and host address, simplifying the creation of printer objects for management tasks. To use the `Printer` class methods, you must first create a printer object using this function.
 
### Syntax
 
    New-specPrinterObject -Name <String> -Driver <String> -PortName <String> -PrinterHostAddress <String>
 
### Parameters
 
- `-Name`: The name of the printer to be managed.
- `-Driver`: The name of the printer driver.
- `-PortName`: The name of the port associated with the printer.
- `-PrinterHostAddress`: The network address for the printer host, used when configuring ports.
 
### Examples
 
#### Create a Printer Object
 
    $printer = New-specPrinterObject -Name 'OfficePrinter' -Driver 'HP LaserJet' -PortName 'OfficePort' -PrinterHostAddress '192.168.1.10'
 
#### Install Printer
 
    $printer.InstallPrinter()
 
---
 
## The `Printer` Class
 
The `Printer` class provides several methods to manage printers, drivers, and port configurations. Below is an overview of its methods and their usage.
 
### Properties
 
- **Name**: The name of the printer.
- **Driver**: The name of the driver associated with the printer.
- **PortName**: The name of the port associated with the printer.
- **PrinterHostAddress**: The network address of the printer for port configuration.
 
### Methods
 
#### `DriverExists()`
 
Checks if the specified printer driver exists.
 
    $exists = $printer.DriverExists()
 
#### `PortExists()`
 
Checks if the specified printer port exists.
 
    $exists = $printer.PortExists()
 
#### `PrinterExists()`
 
Checks if the printer exists.
 
    $exists = $printer.PrinterExists()
 
#### `AddDriver()`
 
Adds the specified printer driver if it does not already exist.
 
    $printer.AddDriver()
 
#### `AddPort()`
 
Adds the specified printer port if it does not already exist.
 
    $printer.AddPort()
 
#### `AddPrinter()`
 
Adds the specified printer if it does not already exist.
 
    $printer.AddPrinter()
 
#### `RemoveDriver()`
 
Removes the specified printer driver if it exists.
 
    $printer.RemoveDriver()
 
#### `RemovePort()`
 
Removes the specified printer port if it exists.
 
    $printer.RemovePort()
 
#### `RemovePrinter()`
 
Removes the specified printer if it exists.
 
    $printer.RemovePrinter()
 
#### `InstallPrinter()`
 
Installs the printer, its driver, and port. It checks if each component exists before installation and only installs those that are missing.
 
    $printer.InstallPrinter()
 
#### `RemoveAll()`
 
Removes the printer, driver, and port if they exist and are not in use.
 
    $printer.RemoveAll()
 
---
 
KEYWORDS
printer management, printer drivers, printer ports, PowerShell module, object-oriented programming, network printers, printer setup, printer configuration, automation, Windows printing
 
 
SEE ALSO
Use the `Get-Help` cmdlet to view the help topics for the `spec.printer.management` module. For example:
 
    Get-Help spec.printer.management
    Get-Help about_spec.printer.management
    Get-Help New-specPrinterObject
 
    To see a list of all available commands in the module (Not including classes), use:
    get-command -Module spec.printer.management