Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Queues moved to cluster

Status
Not open for further replies.
Apr 5, 2005
1,484
US
Our main print server was moved to an MS cluster. My Script no longer enumerates printer information. Is there another class I have to connect to or is there something I have to enable on the cluster? I am able to use WMI CIM Studio, which tells me that Win32_Printer is an available class on the cluster virtual name. I have supplied test code I'm using to resolve the issue. Code still works on any machine that is not in a clustered environment.
Code:
'* FileName:  InstalledPrinters.vbs
'*=============================================================================
'* Script Name: [InstalledPrinters]
'* Created:     [11/02/2006]
'* Author:      Jesse Hamrick
'* Company:     XXXXXXXXXXXXXX
'* Email:       JHmarick@whokilledkenny.net
'* Web:         [URL unfurl="true"]http://www.whokilledkenny.net[/URL]
'* Reqrmnts:    
'* Keywords:    
'*=============================================================================
'* Purpose:  	Enumerates all printers and print information from the local   
'*   			Client. This report is used during the DHCP project to           
'*              ensure that client printers are documented before the move.
'*=============================================================================


'*=============================================================================
'* DECLARE VARIABLES
'*=============================================================================
Dim strComputer
Dim strOS
Dim objWMIService
Dim colOSs
Dim objOS

'*=============================================================================
'* Script Code:
'*=============================================================================
strComputer = InputBox(strComputer, "Enumerate Printers", "Enter the Name of the Print Server:")
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    
Set colOSs = objWMIService.ExecQuery _
	("SELECT * FROM Win32_OperatingSystem")
	For Each objOS In colOSs
		If objOS.Version = "5.1.2600" Then
		OSTypeXP2003
		Else If objOS.Version = "5.2.3790" Then
		OSTypeXP2003
		Else If objOS.Version = "5.0.2195" Then
		OSType2000
		Else
		WScript.Echo "The OS for: " & strComputer & " is not supported."
		End If
	End If
End If
Next

'*=============================================================================
'* SUBROUTINES OR FUNCTION LISTINGS
'*=============================================================================

'*=============================================================================
'* Subroutine:  OSTypeXP2003
'* Created:     [11/02/2006]
'* Author:      Jesse Hamrick
'* Arguments:   
'*=============================================================================
'* Purpose:     This subroutine enumerates printer settings dependent on the
'*              version of the operating system. This sub supports Windows XP
'*              Pro, Windows 2003 Server Standard, and Window 2003 Server
'*              Enterprise.             
'*=============================================================================

Sub OSTypeXP2003	
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Printer")
    WScript.Echo "Printers installed on " & strComputer & "."
    WScript.Echo "The OS For " & strComputer & " is " & objOS.Caption & "."
    WScript.Echo "============================================================="
For Each objPrinter in colInstalledPrinters
    WScript.Echo "Name: " & objPrinter.Name
  	WScript.Echo "Caption: " & objPrinter.Caption
  	WScript.Echo "Comment: " & objPrinter.Comment
  	WScript.Echo "Default Printer? " & objPrinter.Default
  	WScript.Echo "Description: " & objPrinter.Description
    WScript.Echo "DeviceID: " & objPrinter.DeviceID
  	WScript.Echo "Driver: " & objPrinter.DriverName
  	WScript.Echo "Location: " & objPrinter.Location
  	WScript.Echo "Network Printer? " & objPrinter.Network
  	WScript.Echo "Port: " & objPrinter.PortName
  	WScript.Echo "Status: " & objPrinter.Status
  	WScript.Echo VbCrLf
Next
End Sub

'*=============================================================================
'* Subroutine:  OSType2000
'* Created:     [11/02/2006]
'* Author:      Jesse Hamrick
'* Arguments:   
'*=============================================================================
'* Purpose:     This subroutine enumerates printer settings dependent on the
'*              version of the operating system. This sub supports Windows
'*				2000 Professional, 2000 Server, and 2000 Advanced Server.
'*=============================================================================

Sub OSType2000	
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Printer")
    WScript.Echo "Printers installed on " & strComputer & "."
    WScript.Echo "The OS For " & strComputer & " is " & objOS.Caption & "."
    WScript.Echo "============================================================="
For Each objPrinter in colInstalledPrinters
    WScript.Echo "Name: " & objPrinter.Name
  	WScript.Echo "Caption: " & objPrinter.Caption
  	WScript.Echo "Description: " & objPrinter.Description
    WScript.Echo "DeviceID: " & objPrinter.DeviceID
  	WScript.Echo "Driver: " & objPrinter.DriverName
  	WScript.Echo "Location: " & objPrinter.Location
  	WScript.Echo "Port: " & objPrinter.PortName
  	WScript.Echo "Status: " & objPrinter.Status
  	WScript.Echo VbCrLf
Next
End Sub
'*=============================================================================
'* END OF SCRIPT
'*=============================================================================
 
I should also add that I know I can do something with IADsPrintQueue - but I am trying to avoid it if possible.

The script code above is actually used in an .asp page so that other Techs and Help Desk can enumerate printers that are also intalled on clients. I'm sure I could modify the code to check if computer name is a virtual name and based on that run code for IADsPrintQueue info. Just want to pick yoos guyses brains...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top