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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
WTarltonAuthor Commented:
Thats a pretty cool command and looks like it would work. Unfortantly it does not pull up any printer names... :/
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

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
WTarltonAuthor 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.