printer assignments for windows xp workstations within an active directory environment
Posted
by
another_netadmin
on Server Fault
See other posts from Server Fault
or by another_netadmin
Published on 2010-07-20T15:22:48Z
Indexed on
2011/02/12
23:27 UTC
Read the original article
Hit count: 206
I'm using the following script to handle removing any old networked printers from machines and then assigning the propper ones and making one of them the default. This script is assigned to the OU the workstations reside in and uses group policy loopback so all users that login will get the appropriate printers mapped for them.
I tried to use the new Printer Manager as part of W2K3 R2 but when assigning the default this way I get an error that the printer doesn't exist so I'm back to using the script.
One flaw that I'm noticing is that it won't remove any printers that happen to be mapped from an RDP session (we don't see this everywhere but there are a few locations). Is there any way to enumerate all RDP printers and remove them similar to how I'm enumerating and removing networked printers?
'
' Printers.vbs - Windows Logon Script.
'
RemovePrinters
AddPrinters
Sub RemovePrinters()
On Error Resume Next
Dim strPrinter
Set objNetwork = WScript.CreateObject("WScript.Network")
Set colPrinters = objNetwork.EnumPrinterConnections
For i = 0 to colPrinters.Count -1 Step 2
strPrinter=CStr(colPrinters.Item(i+1))
If Not InStr(strPrinter,"\\") = 0 Then
objNetwork.RemovePrinterConnection strPrinter, True, True
End If
Next
End Sub
Sub AddPrinters()
On Error GoTo 0
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\printers1\JH120-DELL5310"
objNetwork.SetDefaultPrinter "\\printers1\Jh120-DELL5310"
End Sub
© Server Fault or respective owner