Advertisement
Advertisement
| 06.26.2008 at 08:07AM PDT, ID: 23518471 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: |
'VBS CODE for enumerating SINGLE Print Server
'On Error Resume next
strComputer = "NYPRINT"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("SELECT * FROM Win32_Printer WHERE PortName LIKE '%10.%'")
For Each objPrinter in colInstalledPrinters
' Wscript.Echo "Port Name: " & objPrinter.PortName
' Wscript.Echo "Collate: " & objPrinter.Collate
WScript.Echo "Printer Name: " & objPrinter.Name & vbCrLf & vbCrLf &_
"Port: " & objPrinter.PortName
' Wscript.Echo "Driver Version: " & objPrinter.DriverVersion
' Wscript.Echo "Description: " & objPrinter.Description
' Wscript.Echo "Horizontal Resolution: " & _
' objPrinter.HorizontalResolution
' If objPrinter.Orientation = 1 Then
' strOrientation = "Portrait"
' Else
' strOrientation = "Landscape"
' End If
' Wscript.Echo "Orientation : " & strOrientation
' Wscript.Echo "Paper Length: " & objPrinter.PaperLength / 254
' Wscript.Echo "Paper Width: " & objPrinter.PaperWidth / 254
' Wscript.Echo "Print Quality: " & objPrinter.PrintQuality
' Wscript.Echo "Scale: " & objPrinter.Scale
' Wscript.Echo "Specification Version: " & _
' objPrinter.SpecificationVersion
' If objPrinter.TTOption = 1 Then
' strTTOption = "Print TrueType fonts as graphics."
' ElseIf objPrinter.TTOption = 2 Then
' strTTOption = "Download TrueType fonts as soft fonts."
' Else
' strTTOption = "Substitute device fonts for TrueType fonts."
' End If
' Wscript.Echo "True Type Option: " & strTTOption
' Wscript.Echo "Vertical Resolution: " & objPrinter.VerticalResolution
Next
'=============================================================
'2ND Script for Enumerating all AD Published Printers
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.CommandText = "Select printerName, serverName from " _
& " 'LDAP://DC=fabrikam,DC=com' where objectClass='printQueue'"
'Problem in this statement is that I can't use LIKE operator to search 'for specific printers like "Select printerName from '"'LDAP://DC=YourDomain,DC=com' were printerName LIKE '%color'" for 'example
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo "Printer Name: " & objRecordSet.Fields("printerName").Value
Wscript.Echo "Server Name: " & objRecordSet.Fields("serverName").Value
objRecordSet.MoveNext
Loop
|