Existing Printers Script

Donate a Coffee

If you found the information helpful, please consider supporting us by donating a coffee to help keep this website alive. Your contribution is greatly appreciated!

Hi everyone,

I wanted to share a quick story. One day, I found myself needing to check the installed printers and their IP addresses on a customer’s computer, but I didn’t want to interrupt them with a bunch of questions or cause any disruptions to their workflow. I knew there had to be a better way to get the information I needed without being intrusive. That’s when it hit me – why not create a script that could do the job for me?

With a little help from PowerShell and SimpleHelp, I put together a script that could pull up all the printers installed on a machine, along with their ports and IP addresses, so I could see exactly what was there. Now, I could quickly check a customer’s setup without bothering them. Let me show you how I did it.

Step 1: Writing the PowerShell Script

PowerShell has some handy cmdlets like Get-Printer and Get-PrinterPort that make accessing printer and port details really straightforward. Here’s the script I came up with to retrieve this information quickly and easily.

PowerShell Script to List Installed Printers and Ports

Get all installed printers

$printers = Get-Printer

Loop through each printer and get the port information

# Get all installed printers

$printers = Get-Printer

# Loop through each printer and get the port information

foreach ($printer in $printers) {

$printerName = $printer.Name

$printerPort = $printer.PortName

# Get details of the printer port

$portDetails = Get-PrinterPort -Name $printerPort

# Display printer and port information

Write-Host “Printer: $printerName”

Write-Host “Port Name: $printerPort”

# Display the IP address if it exists (for network ports)

if ($portDetails.PrinterHostAddress) {

Write-Host “IP Address: $($portDetails.PrinterHostAddress)”

} else {

Write-Host “No IP Address (Local Printer or other type of port)”

}

Write-Host “—————————————-“

}

How It Works:

1. Get-Printer: This command pulls up all the printers installed on a system.

2. Loop through each printer: For each printer, we grab the associated port.

3. Get-PrinterPort: The port details command fetches the IP address if it’s a network printer.

4. Output Information: It displays the printer name, port name, and IP address if available. Local printers will just show “No IP Address.”

This script is perfect for those times when you need to check printers but don’t want to intrude.

Step 2: Running the Script with SimpleHelp

The next step was figuring out how to run this remotely. That’s where SimpleHelp comes in. It lets me set up tools I can run directly on a customer’s machine. Here’s how I set it up:

1. Save the Script: First, I saved the script as List-Printers.ps1.

2. Upload to SimpleHelp: In SimpleHelp’s Tools section, I uploaded the script to create a new tool.

3. Run Remotely: Now, whenever I need to check a customer’s printer setup, I just select the machine in SimpleHelp and run the tool. SimpleHelp executes the script on their end and sends back the results.

What the Output Looks Like

When I run this, I get a clean, simple output like this:

Printer: HP LaserJet Pro MFP

Port Name: IP_192.168.1.45

IP Address: 192.168.1.45

—————————————-

Printer: Microsoft Print to PDF

Port Name: PORTPROMPT:

No IP Address (Local Printer or other type of port)

—————————————-

This tells me exactly what I need to know – which printers are installed, the port they’re using, and the IP address if they’re network printers.

Why This Script Made My Life Easier

The best part? I can gather all this information without ever disturbing the user. It’s fast, accurate, and saves me the time of asking back-and-forth questions or logging into the machine manually to check. Now, when I get a printer-related question, I have all the answers I need in just a few clicks.

If you ever need to check printer details on a remote machine, give this script a try! It’s been a real time-saver for me, and I hope it can be for you, too. Let me know if you try it out – or if you have other script ideas that make remote support easier!

Donate a Coffee

If you found the information helpful, please consider supporting us by donating a coffee to help keep this website alive. Your contribution is greatly appreciated!

Klaws

Writer & Blogger

IT Enthusiast

© 2024 Created by Claudiu Vasilache