This Vbs script will take a print server name supplied from an Input box and send the following information to an Excel spreadsheet:
Print Server Name, Share Name, Comment, Driver Name, Job Count, Location, Port Name, Published, Queued, Shared and status
Vbs Script:
strComputer = InputBox("Enter Print Server Name")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
objExcel.Cells(1, 1).Value = "Name"
objExcel.Cells(1, 2).Value = "Share Name"
objExcel.Cells(1, 3).Value = "Comment"
objExcel.Cells(1, 4).Value = "Driver Name"
objExcel.Cells(1, 5).Value = "Job Count"
objExcel.Cells(1, 6).Value = "Location"
objExcel.Cells(1, 7).Value = "Port Name"
objExcel.Cells(1, 8).Value = "Published"
objExcel.Cells(1, 9).Value = "Queued"
objExcel.Cells(1, 10).Value = "Shared"
objExcel.Cells(1, 11).Value = "Status"
For Each objItem in colItems
Select Case objItem.DetectedErrorState
Case 0 Status = " Online"
Case 1 Status = "Paused"
Case 2 Status = "Pending Deletion"
Case 3 Status = "Error"
Case 4 Status = "Paper Jam"
Case 5 Status = "Paper Out"
Case 6 Status = "Manual Feed"
Case 7 Status = "Paper Problem"
Case 8 Status = "Offline"
Case 256 Status = "IO Active"
Case 512 Status = "Busy"
Case 1024 Status = "Printing"
Case 2048 Status = "Output Bin Full"
Case 4096 Status = "Not Available"
Case 8192 Status = "Waiting"
Case 6384 Status = "Processing"
Case 32768 Status = "Initializing"
Case 65536 Status = "Warming Up"
Case 131072 Status = "Toner Low"
Case 262144 Status = "No Toner"
Case 524288 Status = "Page Punt"
Case 1048576 Status = "User Intervention"
Case 2097152 Status = "Out of Memory"
Case 4194304 Status = "Door Open"
Case 8388608 Status = "Server Unknown"
Case 16777216 Status = "Power Save"
Case Else Status = "UNKNOWN"
End Select
objExcel.Cells(intRow, 1).Value = objItem.Name
objExcel.Cells(intRow, 2).Value = objItem.ShareName
objExcel.Cells(intRow, 3).Value = objItem.Comment
objExcel.Cells(intRow, 4).Value = objItem.DriverName
objExcel.Cells(intRow, 5).Value = objItem.JobCountSinceLastReset
objExcel.Cells(intRow, 6).Value = objItem.Location
objExcel.Cells(intRow, 7).Value = objItem.PortName
objExcel.Cells(intRow, 8).Value = objItem.Published
objExcel.Cells(intRow, 9).Value = objItem.Queued
objExcel.Cells(intRow, 10).Value = objItem.Shared
objExcel.Cells(intRow, 11).Value = Status
intRow = intRow + 1
Next
objExcel.Range("A1:K1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Set objExcel = Nothing
Set objWMIService = Nothing
Set colItems = Nothing
No Comments