How list shared printers on server without admin rights

4.2k views Asked by At

I wish to list all printer queues on a list of print servers in PowerShell (or wrapped native cmd command if necessary).

The difficulty here is that I don't have admin rights on the servers, so I cannot use WMI to query them.

I have tried to use Test-Path \\serverName\queueName to no avail (seemed a good option to me, since for instance start \\serverName\queueName opens the queue just fine).

How can I achieve this?

EDIT: I'm running Windows 7 and I don't know which OS runs on the servers (2008, 2012 maybe).

3

There are 3 answers

0
BenH On BEST ANSWER

If they are published in Active Directory, you could look up the printqueue objects:

Get-ADObject -LDAPFilter "(objectCategory=printQueue)"

Edit:

Without being AD published, then you could enumerate them from the SMB shares for the Point and Print Queues using net view \\servername

1
TheMadTechnician On

Depending on your OS this really could be as simple as using Get-Printer.

$NetworkQs = $ServerList | ForEach{Get-Printer -ComputerName $_ }

I don't think this was available before Win8, maybe 8.1.

0
sodawillow On

This is what I finally used. Kudos to @BenH, didn't think of the net command.

$servers = "printer01", "printer02"

$servers |
    ForEach-Object {
        $server = $_
        net view \\$server |
            Where-Object { $_ -match "Print" } |
            ForEach-Object {
                $parts = $_ -split "\s{2,}"
                $item = New-Object PSObject
                $item | Add-Member -MemberType NoteProperty -Name Server -Value $server
                $item | Add-Member -MemberType NoteProperty -Name Queue -Value "\\$server\$($parts[0])"
                $item | Add-Member -MemberType NoteProperty -Name Description -Value $parts[2]
                $item
            }
    }

Output:

Server      Queue                 Description            
------      -----                 -----------            
...         ...                   ...
...         ...                   ...