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!

Deploy printers via Active Directory OU 1

Status
Not open for further replies.

baronne

Technical User
May 31, 2003
166
Hi,
I am looking for a way of deploying printers via policy in AD. Presently we use a script which is just so very messy. It works by adding printers based on the computer name.
I found a product by Desktop Standard called PolicyMaker The trouble is this product is so expensive as it is licensed per user and we have around 1000 users!
Are there any alternative products out there that extend AD to include deploying printers?
cheers
baronne

:: baronne
------------------
"lekker, shot bru
 
R2? wassat?

:: baronne
------------------
"lekker, shot bru
 
dag nabbit... that sounds brilliant, but - we'll have to wait for this R2 I guess... is it just an upgrade from Win2K3 Standard or is it essentially the next server OS?


:: baronne
------------------
"lekker, shot bru
 
It is the second release out of windows 2003 with cool added features but it is not the next major server OS.

Justin
 
Are you using VBscript?

I use VB scripts to manage our printers and i've found it to be very efficient and very low in management overhead. Only one script is required for our entire domain and this adds our printers at logon.
 
is it just an upgrade to Windows 2003 R2 - as in service pack - or is a full-on upgrade?


:: baronne
------------------
"lekker, shot bru
 
It's just a collection of addons and improvements for 2003 server all rolled into one update, it does require SP1 to be installed but that is about all.
When you install the second cd which is the R2 part it makes a small change to the schema and thats about all you will notice, you can then add the new features through add/remove programs.
 
cool. so do you download this update or is it a purchase?

:: baronne
------------------
"lekker, shot bru
 
If you are a software assurance customer then you get it free otherwise it's an upgrade. You can download a free trial from MS to see if the features are what you are looking for.
 
thanks... I think we're unfortunately not on an SA agreement.. hmm..

:: baronne
------------------
"lekker, shot bru
 
I'm currently using a VBScript that maps printers based on the OU that contains the computer account. So any user can sit down at any computer and get a set of printers that are near the computer.

Here's a very primitive version of my current script, but you'll get the idea...
Code:
Option Explicit

On ERROR RESUME Next

Dim wshShell, wshNetwork, objDomain, objTrans, objPrinters
Dim strComputerDN, strComputerOU, strNum
Dim arrSplitDN

' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

Set wshShell = CreateObject("WScript.Shell")
Set wshNetwork = CreateObject("WScript.Network")
Set objDomain = getObject("LDAP://rootDse")
Set strComputerOU = Nothing

' Use the NameTranslate object to convert the NT name of the computer to
' the Distinguished name required for the LDAP provider. Computer names
' must end with "$".
Set objTrans = CreateObject("NameTranslate")
objTrans.Set ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_NT4, wshNetwork.UserDomain & "\" _
& wshNetwork.computerName & "$"
strComputerDN = objTrans.Get(ADS_NAME_TYPE_1779)
'WScript.Echo strComputerDN

' Split the DN on the comma delimeter
arrSplitDN = Split(strComputerDN, ",")

' Determine where computer is in AD.  If computer account is in computers,
' then error and quit.  If computer is a laptop determine IP subnet.
If UCase(arrSplitDN(1)) = "CN=COMPUTERS" Then
	WScript.Echo "Computer is in Computers Container.  No printers" _
	& " assigned.  Contact your administrator."
	WScript.Quit
	
Elseif UCase(arrSplitDN(1)) = "OU=DOMAIN CONTROLLERS" Then
	WScript.Echo "Computer is a Domain Controller.  Exiting Script."
	WScript.Quit
	
Else
	'Combine OU entries back into one entry delimeted with comma.
	For strNum = 0 To UBound(arrSplitDN)
		If Left(arrSplitDN(strNum),3) = "OU=" Then
			If strComputerOU = "" Then
				strComputerOU = arrSplitDN(strNum)
			Else
				strComputerOU = strComputerOU & "," & arrSplitDN(strNum)
			End If
		End If
	Next
End If

'Remove old network printers
'Enumerate all printers first, then delete all network printers
Set objPrinters = wshNetwork.EnumPrinterConnections
For strNum = 0 To objPrinters.Count - 1 Step 2
    If Left(objPrinters.Item(strNum +1),2) = "\\" Then
      wshNetwork.RemovePrinterConnection objPrinters.Item(strNum +1),True,True
    End If
Next

strComputerOU = UCase(strComputerOU)

'Assign printers based on OU membership
Select Case strComputerOU
	Case "OU=COMPUTERS,OU=NORTH,OU=BUILDING40"
		wshNetwork.AddWindowsPrinterConnection "\\Server1\Printer1"
		
	Case "OU=COMPUTERS,OU=SOUTH,OU=BUILDING40"
		wshNetwork.AddWindowsPrinterConnection "\\Server1\Printer2"
	
End Select

My current script performs a variety of other tasks including: ignore user installed network printers, give additional printers based on IP subnet a laptop is currently in, etc... But posting a 1200 line script (including comments) is a little excessive.

Good Luck!

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Can you deploy printers that are connected directly to the LAN via TCP-IP? I have printers on my company that uses HP Jetdire ct and such devices to "share them selfs"...

Ben
 
You would typically host the printer share on a server and that would print to the IP port of the network printer. Otherwise you would have to create the TCP/IP printer port on each local station.
 
Ok. Lucky me that we only have 10 computers on our LAN :D
 
I'm not sure that I would script "local" printers since that affects all users of the computer, not just the current user. Just create the printer at deployment time.

Unfortunately network print queues only stay with the person who is logged in at the time of mapping. The printer simply does not exist for any other user who sits down at the machine until they map it. Scripting, as demonstrated above, gives you a way to "simulate" the local printer experience while using network print queues.

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Nope i don't go down that line either PScottC , it's much easier to use shared network printers as you say.
 
Don't get me wrong... I despise the idea of setting up local printers for any network that contains a server that could host the print queues. But users don't understand the benefits to administrators sometimes. I think that being able to control driver versions, secure special printers, be able to search printers from AD, etc, etc, etc... is what should be done.

I'm just trying to suggest a way to get these printers to peoples' computers. I've found that assigning printers by group or by person doesn't really take into account that people move around and that printers and computers generally don't. What good is a printer to a user when the user has gone to another office in another building?

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top