Enumerating printers on a print cluster with Powershell

Hi all,
We have a requirement to change security on every printer within our organization. Some of the print servers on our domain are in clusters and some are standalone.

On the standalone I can pull printers just fine with this WMI query:

$Printers = Get-WmiObject -class "Win32_Printer" -computername $Computer

However when I try to query a cluster I only get 1 printer returning which is the only local printer installed on that server even though there are 100's of other printers.

How can I query the printers in the cluster and modify the permissions on them?

Thanks
WTarltonAsked:
Who is Participating?
 
WTarltonConnect With a Mentor Author Commented:
I figured it out. Had to pull it out of the registry. See Code:

$Spoolers = @()
$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 *
            Write-Host -ForegroundColor cyan $Printer.PSChildName
            $values = Get-ItemProperty $Printer.pspath
                                          
      }
}
0
 
x-menIT super heroCommented:
try:

>cluster.exe <YourClusterName> RES | select-string -pattern <printerResourceType>

I'm not in place to test and give you the exact command, Monday I'll be able to give you the exact command.
0
 
x-menIT super heroCommented:
mix the cluster.exe command with the Select-String cmdlet:

cluster.exe <YourClusterName> RES | Select-String -Pattern "Print Spooler"

and it will list you all the printers configured in the cluster <YourClusterName> :

Resource             Group                Node            Status


from here, you can load them into a variable and "work" them
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
WTarltonAuthor Commented:
Thats a pretty cool command and looks like it would work. Unfortantly it does not pull up any printer names... :/
0
 
x-menIT super heroCommented:
is there a pattern to the printer resource names that are created on the cluster resources?

the command 'cluster.exe <YourClusterName> RES' will pull all the resources in the cluster, so if you can filter these resources using the 'select-string' cmdlet, you'll get your list
0
 
x-menIT super heroCommented:
cool
0
 
x-menIT super heroCommented:
rectifying my previous post/command...:

cluster.exe <YourClusterName> RES /prop | Select-String -Pattern "Print Spooler"
0
All Courses

From novice to tech pro — start learning today.