Issue trying to query print server with thousands of printers installed RRS feed

  • Question

  • Hi Everyone.

    Not sure if this is the correct Forum or not....

    I'm having an issue getting a list of printers remotely from a server (2012R2) that has 10,000 local print queues installed.  I've tried both C# and PowerShell code to retrieve the printers and both fail when accessing it remotely.  When I run the same commands locally on the print server with 10,000 printers, it works just fine, just not when I access it remotely.  I originally had 1000 printers installed on the server, and the commands listed below actually worked remotely.  When I started adding more printers, thousands more, it stopped returning any results at all.  It seems there is a threshold that breaks the server depending upon the number of printers installed.  Any ideas?

    PowerShell code that fails remotely: 

    Get-Printer -ComputerName "ServerWith10000LocalPrinters"

    Error message:

    Get-Printer : An error occurred while performing the specified operation.  See the error details for more information.
    At line:1 char:1
    + Get-Printer -ComputerName "ServerWith10000LocalPrinters"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidData: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Get-Printer], CimException
        + FullyQualifiedErrorId : HRESULT 0x8007000d,Get-Printer

    My C# code that I've tried remotely that fails

    PrintServer printServer = new PrintServer("\\\\PrintServerwith10000Printers");
    var allPrintqueues = printServer.GetPrintQueues().OrderBy(x=>x.Name);
    foreach(var i in allPrintqueues)

    Error message:

    System.NullReferenceException was unhandled
      Message=Object reference not set to an instance of an object.
           at MS.Internal.PrintWin32Thunk.AttributeNameToInfoLevelMapping.InfoLevelCoverageList.Release()
           at MS.Internal.PrintWin32Thunk.EnumDataThunkObject.GetPrintSystemValuesPerPrintQueues(PrintServer printServer, EnumeratedPrintQueueTypes[] flags, Queue`1 printObjectsCollection, String[] propertyFilter)
           at System.Printing.PrintQueueCollection..ctor(PrintServer printServer, String[] propertyFilter)
           at System.Printing.PrintServer.GetPrintQueues()
           at PrintMgmt.Program.SearchPrinters() in C:\Users\hm3307\Documents\Visual Studio 2015\Projects\PrintMgmt\PrintMgmt\Program.cs:line 64
           at PrintMgmt.Program.Main(String[] args) in C:\Users\hm3307\Documents\Visual Studio 2015\Projects\PrintMgmt\PrintMgmt\Program.cs:line 52
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()

    Side note:  Querying WMI for the full list isn't really feasible since it takes around 5 minutes to query 10,000 printers...

    • Edited by Nordy1145 Thursday, September 15, 2016 2:46 PM
    Thursday, September 15, 2016 2:36 PM

All replies

  • Did you find a resolution to this? I recently had this happen with my print servers. I have roughly 4000 print queues on each print server and I am getting the same error when I run get-printer remotely against the print server. Like you, I can run the powershell command locally and it works fine. 

    Monday, February 13, 2017 4:14 PM