Assigning Printers w/ GPO per machine - Workaround

Assigning Printers w/ GPO per machine - Workaround

Post by Aziraphal » Sat, 08 May 2004 15:07:23


I have a very inelegant solution, so if someone has
something better, please let me know.

Basically, I run a machine startup script to copy a
generically named printer install script to a directory on
the client. Then I have a user logon script that calls
the local copy of the printer script.

As I said, inelegant, but it solves the problem for the
time being. I would still prefer something cleaner.

A.

We
solution
with
to
profile.
run
printers
level.
 
 
 

Assigning Printers w/ GPO per machine - Workaround

Post by Andrew Mit » Sat, 08 May 2004 22:24:03

"Aziraphale" < XXXX@XXXXX.COM > said


You could call a vbscript routine from the login script to determine the OU
then install the printer based on that OU.
The ADSystemInfo object will give you the DN (Distinguished Name) of the
computer, which is a string containing (among other details) the OU of the
machine.



'********** Start Script **********
'First - Delete any printers installed during previous login

set wshNetwork = CreateObject ("WScript.Network")

'Enumerate all existing network printers and remove them
Set clPrinters = WshNetwork.EnumPrinterConnections
On Error Resume Next
For i = 0 to clPrinters.Count - 1 Step 2
wshNetwork.RemovePrinterConnection clPrinters.Item(i+1), true
Next

'Now add a printer based on the OU.

Set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName

'If we are in the OU called "OU1" add a printer called "Printer1"
if instr(1,strComputerDN,"OU1",1)>0 then
wshNetwork.AddWindowsPrinterConnection "\\PrintServer\Printer1"
'Make it the default printer
wshNetWork.SetDefaultPrinter "\\PrintServer\Printer1"

'If we are in the OU called "OU2" add a printer called "Printer2"
Else if instr(1,strComputerDN,"OU2",1)>0 then
wshNetwork.AddWindowsPrinterConnection "\\PrintServer\Printer2"
'Make it the default printer
wshNetWork.SetDefaultPrinter "\\PrintServer\Printer2"

'Keep adding sections for each OU and printer

End if


'********** End Script **********

You will need to test this and check it for any syntax errors. I don't have
ADSI installed or a domain handy ATM to test it with but the basics are
there.

The only shortcoming with this is if you have any parent/child OU's. If you
have your OU's set like this the script will only pick up the first OU in
the If....End If structure.

Let me know if you want any more info.

--
Andy

 
 
 

Assigning Printers w/ GPO per machine - Workaround

Post by BOFH123 » Fri, 02 Jul 2004 09:05:28

work for a university and this is a really large problem for us. My cheap
(free) solution is to use the login script to get the computer name and set
the printer based on that. If you move PCs frequently this will not be a
good solution. Here is a copy of my login script:

if '%COMPUTERNAME%' == '0421PC' rundll32 printui.dll,PrintUIEntry /y /n
"\\pserver1\G158"
if '%COMPUTERNAME%' == '0426PC' rundll32 printui.dll,PrintUIEntry /y /n
"\\pserver1\G158"
if '%COMPUTERNAME%' == '0429PC' rundll32 printui.dll,PrintUIEntry /y /n
"\\pserver1\G158"
if '%COMPUTERNAME%' == '0430PC' rundll32 printui.dll,PrintUIEntry /y /n
"\\pserver1\G158"

if '%computername%' == '1591PC' rundll32 printui.dll,PrintUIEntry /y /n
"\\pserver2\M120"
if '%computername%' == '1612PC' rundll32 printui.dll,PrintUIEntry /y /n
\\pserver2\M120"

if '%COMPUTERNAME%' == '2798PC' rundll32 printui.dll,PrintUIEntry /y /n
"\\pserver1\M109"
if '%COMPUTERNAME%' == '2799PC' rundll32 printui.dll,PrintUIEntry /y /n
\\pserver1\M109"

This is not elegant solution, but it works. Here is what I do to make it
work:

Install XP, hotfixes, software, join to domain, etc.
Create a new user on the domain with domain admin rights.
Login to the PC as the new user.
Set all of the settings you want (show standard and formatting toolbars on
two rows, always show full menus, etc). Get the PC exactly as you want it.
Install all of the printers you want your users to print to.
Logoff
Login as the local admin.
Go into the user profiles area and select the account you just created,
select copy. Find the default user directory and give everyone permission.
Click on OK.
Go to the default user directory, right click, select properties, security
tab, select everyone and uncheck the write permission. User only need read
access.
Use this as your image.

Now when a user logs on to the domain, all possible printers are there and
the login script makes the correct printer the default printer. I worte a
little group policy to hide the printer and faxes option on the start menu.

Now if only MS would allow administrators to set printers at the OU level,
my life and the lifes of many other administrators would be simplified.
Perhaps we might see this HIGHLY NEEDED functionality in Windows 2003 SP1?


"Aziraphale" < XXXX@XXXXX.COM > wrote in message
news:975d01c433f9$908e88b0$ XXXX@XXXXX.COM ...


 
 
 

Assigning Printers w/ GPO per machine - Workaround

Post by patrickbur » Thu, 09 Sep 2004 01:41:55

Ok, so I am going to try this one. Does anyone know how to set by th
computer assigned OU?
This is for a school and students need to have access to printers b
location of pc.
Also, I just let the last one in the list be the default printe
assigned from the user configuration login script folder. Any way I ca
have the default be left alone?
Patrick Burwell
CNCNJ.com

Here is my contribution:
I used the similar script only simplified and used the login from th
gpo for the user configuration.

Option Explicit
Dim oNetwork, sPrintPath
Set oNetwork = CreateObject("WScript.Network")
sPrintPath = "\\print server\printer sharename"
oNetwork.AddWindowsPrinterConnection sPrintPath
oNetwork.SetDefaultPrinter sPrintPath


Andrew Mitchell wrote:


-
patrickburwel
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message647920.htm

 
 
 

Assigning Printers w/ GPO per machine - Workaround

Post by Andrew Mit » Tue, 14 Sep 2004 00:07:41

atrickburwell < XXXX@XXXXX.COM > said


The script I posted earlier (that you quoted below) will do this.


Just comment out or remove the lines containing:
wshNetWork.SetDefaultPrinter


Andy.