I have cobbled to gether this script to allow me to automatically use 2003 AD (we have Win2k PC's) to map the default printer based on membership of 4 distribution groups
1st Floor User, 2ndFloor User etc
' New Logon script
On Error Resume Next
'4 initial object creation
Dim objNetwork, objGroup , UserObj
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
DomainString = "Company.co.uk"
UserString = WSHNetwork.UserName
set objNetwork = WScript.createObject("WScript.Network")
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'14 Welcome Message
Dim strDomain, strUser
strDomain = ObjNetwork.UserDomain
strUser = ObjNetwork.UserName
MsgBox "Welcome to the " & strDomain & " Network, " & strUser & "!"
'21 Drive Mapping
objNetwork.MapNetworkDrive "G:", "\\Servername\Data1"
objNetwork.MapNetworkDrive "H:", "\\Servername\Accounts"
objNetwork.MapNetworkDrive "I:", "\\Servername\Documents"
objNetwork.MapNetworkDrive "J:", "\\Servername\Personnel"
objNetwork.MapNetworkDrive "K:", "\\Servername\Trescray Utils"
objNetwork.MapNetworkDrive "L:", "\\Servername\Electrical"
objNetwork.MapNetworkDrive "M:", "\\Servername\Archive"
objNetwork.MapNetworkDrive "N:", "\\Servername\Fuji"
objNetwork.MapNetworkDrive "O:", "\\Servername\Homedirs\" & strUser
objNetwork.MapNetworkDrive "P:", "\\Servername\Apps"
objNetwork.MapNetworkDrive "T:", "\\Servername\TestResults"
objNetwork.MapNetworkDrive "V:", "\\Servername\Fiber"
objNetwork.MapNetworkDrive "X:", "\\Servername\Fluor"
objNetwork.MapNetworkDrive "Z:", "\\Servername\Admin Documentation"
'38 Printer Mapping
objNetwork.AddWindowsPrinterConnection "\\Servername\First Floor C450", "Konica Minolta C450 PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername2\Second Floor C450", "Konica Minolta C450 PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername2\First Floor C450", "Konica Minolta C450 PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername\2nd Floor C450", "Konica Minolta C450 PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername\First Floor - Laserjet 2200dn", "HP Laserjet 2200 Series PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername2\First Floor - Laserjet 2200dn", "HP Laserjet 2200 Series PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername\Second Floor - Laserjet 4050", "HP Laserjet 4050 Series PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername2\Second Floor - LaserJet 4050", "HP Laserjet 4050 Series PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername\StoresLJ3200", "HP Laserjet 4M"
objNetwork.AddWindowsPrinterConnection "\\Servername2\Stores Department - LaserJet 3200", "HP Laserjet 4M"
'55 Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
'59 Check for group memberships and take needed action
Case "1stFloor User"
objNetwork.SetDefaultPrinter "\\Servername\First Floor C450"
Case "2ndFloor User"
objNetwork.SetDefaultPrinter "\\Servername\Second Floor C450"
Case "3rdFloor User"
objNetwork.SetDefaultPrinter "\\Servername\Second Floor C450"
Case "CAD User"
objNetwork.AddWindowsPrinterConnection "\\Servername\CAD Department - DesignJet 800", "HP DesignJet 800 42 by HP"
objNetwork.AddWindowsPrinterConnection "\\Servername2\CAD Department - DesignJet 800", "HP DesignJet 800 42 by HP"
End Select
Next
'74 Synchronizes the time with Main AD Server our NTP Server
The drives are mapped the printers added But I cannot get teh default printer section lines 55 -73 to select a group from AD by which to decide what floor they are on
Can anyody see what I have missed please ?
1st Floor User, 2ndFloor User etc
' New Logon script
On Error Resume Next
'4 initial object creation
Dim objNetwork, objGroup , UserObj
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
DomainString = "Company.co.uk"
UserString = WSHNetwork.UserName
set objNetwork = WScript.createObject("WScript.Network")
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'14 Welcome Message
Dim strDomain, strUser
strDomain = ObjNetwork.UserDomain
strUser = ObjNetwork.UserName
MsgBox "Welcome to the " & strDomain & " Network, " & strUser & "!"
'21 Drive Mapping
objNetwork.MapNetworkDrive "G:", "\\Servername\Data1"
objNetwork.MapNetworkDrive "H:", "\\Servername\Accounts"
objNetwork.MapNetworkDrive "I:", "\\Servername\Documents"
objNetwork.MapNetworkDrive "J:", "\\Servername\Personnel"
objNetwork.MapNetworkDrive "K:", "\\Servername\Trescray Utils"
objNetwork.MapNetworkDrive "L:", "\\Servername\Electrical"
objNetwork.MapNetworkDrive "M:", "\\Servername\Archive"
objNetwork.MapNetworkDrive "N:", "\\Servername\Fuji"
objNetwork.MapNetworkDrive "O:", "\\Servername\Homedirs\" & strUser
objNetwork.MapNetworkDrive "P:", "\\Servername\Apps"
objNetwork.MapNetworkDrive "T:", "\\Servername\TestResults"
objNetwork.MapNetworkDrive "V:", "\\Servername\Fiber"
objNetwork.MapNetworkDrive "X:", "\\Servername\Fluor"
objNetwork.MapNetworkDrive "Z:", "\\Servername\Admin Documentation"
'38 Printer Mapping
objNetwork.AddWindowsPrinterConnection "\\Servername\First Floor C450", "Konica Minolta C450 PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername2\Second Floor C450", "Konica Minolta C450 PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername2\First Floor C450", "Konica Minolta C450 PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername\2nd Floor C450", "Konica Minolta C450 PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername\First Floor - Laserjet 2200dn", "HP Laserjet 2200 Series PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername2\First Floor - Laserjet 2200dn", "HP Laserjet 2200 Series PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername\Second Floor - Laserjet 4050", "HP Laserjet 4050 Series PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername2\Second Floor - LaserJet 4050", "HP Laserjet 4050 Series PCL"
objNetwork.AddWindowsPrinterConnection "\\Servername\StoresLJ3200", "HP Laserjet 4M"
objNetwork.AddWindowsPrinterConnection "\\Servername2\Stores Department - LaserJet 3200", "HP Laserjet 4M"
'55 Now check for group memberships and map appropriate drives
For Each GroupObj In UserObj.Groups
Select Case GroupObj.Name
'59 Check for group memberships and take needed action
Case "1stFloor User"
objNetwork.SetDefaultPrinter "\\Servername\First Floor C450"
Case "2ndFloor User"
objNetwork.SetDefaultPrinter "\\Servername\Second Floor C450"
Case "3rdFloor User"
objNetwork.SetDefaultPrinter "\\Servername\Second Floor C450"
Case "CAD User"
objNetwork.AddWindowsPrinterConnection "\\Servername\CAD Department - DesignJet 800", "HP DesignJet 800 42 by HP"
objNetwork.AddWindowsPrinterConnection "\\Servername2\CAD Department - DesignJet 800", "HP DesignJet 800 42 by HP"
End Select
Next
'74 Synchronizes the time with Main AD Server our NTP Server
The drives are mapped the printers added But I cannot get teh default printer section lines 55 -73 to select a group from AD by which to decide what floor they are on
Can anyody see what I have missed please ?