I'm writing a powershell script for windows 7 to replace some printer connections on users' desktops and I need to be able to get a list of print queues on a windows print server. I do not have access to the print server beyond browsing, connecting and printing to the print queues.
Problem: When querying the server for a list via win32_printer with get-wmiobject, I get access denied.
PS M:> Get-WmiObject -Class Win32_Printer -computername newprintservername
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) At line:1 char:14 + Get-WmiObject <<<< -Class Win32_Printer -computername newprintservername + CategoryInfo : NotSpecified: (:) [Get-WmiObject],UnauthorizedAccessException + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
Complication: "newprintservername" could actually be one of two different servers, so I want to be able to check for the existence of print queue before trying to connect to it. I suppose I could attempt a connection, check the printer connections and if it doesn't exist, attempt connection to the other server, but I'd like to not have to take that route unless absolutely necessary.
Any ideas? Thanks in advance.