Clear Remote Downlevel Documents on a Print Server

VBScript that clears the Remote Downlevel Documents.
Takes 1 Argument (Computername)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
On Error Resume Next
strComputer = WScript.Arguments(0)
Set shell = Wscript.CreateObject("Wscript.Shell")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select Document, Name, Owner, JobId from Win32_PrintJob where Document = 'Remote Downlevel Document'",,48)
Dim varCounter
    Wscript.Echo vbCrLf & "Remote Dowlevel Documents on " & WScript.Arguments(0) & ":" & vbCrLf
    Wscript.Echo "JobID" & vBTab & "Owner" & vBTab & vBTab & "Name, ID" & vbCrLf
    varCounter=0
For Each objPrintJob in colItems
    varCounter=varCounter+1
    Wscript.Echo objPrintJob.JobId & vBTab & objPrintJob.Owner & vBTab & objPrintJob.Name
    	If (WScript.arguments(1)) = "/del" Then
    	Shell.Run ("net print \\" & WScript.Arguments(0) & " " & objPrintJob.JobId & " /DELETE"),0,true
    	Else
    	End If
Next
    WScript.Echo vbCrLf & "Total Remote Dowlevel Documents found on " & WScript.Arguments(0) & ": " & varCounter

Leave a Reply