back to the registry edit ↗

Getting Printer Info From a Print Server Cluster

WMI won't talk to clustered print servers. Registry spelunking and PowerShell to the rescue.

Kind
wrote
Span
note
Tags
powershell, sysadmin
Read
3 min

Originally published on blog.benvirgilio.com

Unfortunately it is not possible to use WMI to obtain information from a clustered print server regarding printers. This makes it very difficult to dump a complete list of printers within the domain you are administering.

However this information is stored in an alternate location within the registry (HKLM:\Cluster\Resources), after a few hours of research I stumbled across this post on Experts Exchange:

http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_25647470.html

I made some slight modifications to WTarlton’s script in order to extract the name, location and port (IP address) from the keys and save the output to a CSV file. It took me some time to find this information and a bit of trial and error to discover that Get-WMIObject doesn’t play nice with server clusters, so I hope that by reproducing WTarlton’s script and making some modifications this will save some time for other people running into the same issues.

##########################################################################
#
# Filename: Utility-GetPrintersFromCluster.ps1
# Author: Ben Virgilio
# Revision: 1.0
# Updated On: 6/27/2013
#
# This script will extract printer names, IP address and location from
# HKLM:\Cluster\Resources.
#
# Registry Code Credit:
# http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_25647470.html
#
# Revision History:
# 1.0 - Initial script
#
##########################################################################

$Spoolers = @()
$printvalues = @()
$Resources = Get-ChildItem HKLM:\Cluster\Resources
foreach ($Resource in $Resources){
	$values = Get-ItemProperty $Resource.pspath
	foreach ($value in $values){
		if ($value.Type -ne $Null -and $value.Type.tolower() -eq "print spooler"){
			[string]$Path = $Resource.pspath + "\Parameters\Printers"
			$Spoolers += $Path
		}
	}
}

foreach ($Spooler in $Spoolers){
	$Printers = Get-ChildItem $Spooler
	foreach ($Printer in $Printers){
		#$Printer | fl *
		$value = Get-ItemProperty $Printer.pspath
		$printvalues += $value
	}
}

$printvalues | Select-Object Name,Location,Port | Export-CSV C:\printerlist.csv