Reputation: 13176
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).
Upvotes: 0
Views: 4686
Reputation: 13176
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
------ ----- -----------
... ... ...
... ... ...
Upvotes: 0
Reputation: 10044
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
Upvotes: 1
Reputation: 36332
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.
Upvotes: 0