Announcement

Collapse
No announcement yet.

Purge printing queues in print spooler cluster env

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Purge printing queues in print spooler cluster env

    Hi,

    We are running our printer server in a cluster environment and have approximately 260 printers.

    Once in a few days I go and manually delete all the stuck queues in the printer (due to "out of paper" or "error printing" issues).

    I'm looking for a script that I can run on a regular bases (scheduled task maybe) which will run on all the printers in the printer cluster and purge all of the printers queues.

    I found this script in the script center, but it only runs on local printers and any tries to change it's parameters to the cluster printer name did nothing.

    -----------------------------------------------
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colInstalledPrinters = objWMIService.ExecQuery _
    ("Select * from Win32_Printer")
    For Each objPrinter in colInstalledPrinters
    objPrinter.CancelAllJobs()
    Next
    -----------------------------------------------

    Any help will be appreciated.

    10X,

    Poly.

  • #2
    Re: Purge printing queues in print spooler cluster env

    try this:
    Code:
    strComputer="prnServName"
    
    Set objComputer = GetObject("WinNT://" & strComputer)
    objComputer.Filter = Array("printQueue")
    
    For Each objPrinter in objComputer
        'wsh.echo objPrinter.name
        objPrinter.Purge 
    Next
    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Purge printing queues in print spooler cluster env

      10X

      But yours I believe will run locally only and I need to run it from a remote server.
      If I'll have cluster failover the script will get stuck.

      Anyway, just got this one, tried it and it works remotely:


      -----------------------------------------------------
      On Error Resume Next

      Const ADS_SCOPE_SUBTREE = 2

      Set objConnection = CreateObject("ADODB.Connection")
      Set objCommand = CreateObject("ADODB.Command")
      objConnection.Provider = "ADsDSOObject"
      objConnection.Open "Active Directory Provider"
      Set objCommand.ActiveConnection = objConnection

      objCommand.Properties("Page Size") = 1000
      objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

      objCommand.CommandText = _
      "SELECT Name FROM 'LDAP://dc=BLA,dc=BLA,dc=BLA' WHERE objectCategory='printQueue'"
      Set objRecordSet = objCommand.Execute
      objRecordSet.MoveFirst

      Do Until objRecordSet.EOF
      If InStr(1, objRecordSet.Fields("Name").Value, "PrintClusterName", vbTextCompare) = 1 Then
      'Wscript.Echo Right(objRecordSet.Fields("Name").Value,Len(objRec ordSet.Fields("Name").Value) - 10)
      Set objPrinter = GetObject("WinNT://PrintClusterName/" & Right(objRecordSet.Fields("Name").Value,Len(objRec ordSet.Fields("Name").Value) - 10))
      objPrinter.Purge
      End if
      objRecordSet.MoveNext
      Loop
      -----------------------------------------------------


      10X anyway!

      Poly

      Comment

      Working...
      X