Guest Laphan Posted May 12, 2008 Posted May 12, 2008 Hi All Hope you can help. Basically I need to map a printer to certain PCs so that all the PCs on the first floor have the ability to print to one printer and all the PCs on ground level can print to another. To do this, I tried the following: a) Created a new OU in AD called 'Upstairs PCs'. b) Drag and dropped one particular PC from the default Computers folder to my new OU. c) Went into GPO editor and created a new GPO for this OU called 'Upstairs PCs'. d) Went to User Config > Windows Comp > Logon and dropped in a script file that uses the usual printdll command line to map the upstairs printer. However when I log onto the relevant test PC, the printer doesn't map. I get no error messages, but I don't get a printer either. Is it not possible to execute my usual user config OU scripts AND this new Upstairs PC script? I also tried putting my new script file in the Startup part of Computer Config > Windows Comp of my Upstairs OU, but this also didn't make a diff. NOTE: I have done gpupdate every time I've tried the above. Am I doing something daft? Rgds Laphan
Guest Masterplan Posted May 12, 2008 Posted May 12, 2008 RE: Mapping printers to particular machines Hi Laphan, First of all, you should put the script in the startup part of computer config. If after a computer restart does not work, check again your script on a specific machine to see if it's working (if it's not, post here the script please) and see if another group policy does not block this one (a domain group policy for example with the no override option). Have a nice day! "Laphan" wrote: > Hi All > > Hope you can help. > > Basically I need to map a printer to certain PCs so that all the PCs on the > first > floor have the ability to print to one printer and all the PCs on ground > level can print to another. > > To do this, I tried the following: > > a) Created a new OU in AD called 'Upstairs PCs'. > > b) Drag and dropped one particular PC from the default Computers folder to > my new OU. > > c) Went into GPO editor and created a new GPO for this OU called 'Upstairs > PCs'. > > d) Went to User Config > Windows Comp > Logon and dropped in a script file > that uses the usual printdll command line to map the upstairs printer. > > However when I log onto the relevant test PC, the printer doesn't map. I > get no error messages, but I don't get a printer either. > > Is it not possible to execute my usual user config OU scripts AND this new > Upstairs PC script? > > I also tried putting my new script file in the Startup part of Computer > Config > Windows Comp of my Upstairs OU, but this also didn't make a diff. > > NOTE: I have done gpupdate every time I've tried the above. > > Am I doing something daft? > > Rgds > > Laphan > > > >
Guest Richard Mueller [MVP] Posted May 12, 2008 Posted May 12, 2008 Re: Mapping printers to particular machines Laphan wrote: > Hope you can help. > > Basically I need to map a printer to certain PCs so that all the PCs on > the > first > floor have the ability to print to one printer and all the PCs on ground > level can print to another. > > To do this, I tried the following: > > a) Created a new OU in AD called 'Upstairs PCs'. > > b) Drag and dropped one particular PC from the default Computers folder to > my new OU. > > c) Went into GPO editor and created a new GPO for this OU called 'Upstairs > PCs'. > > d) Went to User Config > Windows Comp > Logon and dropped in a script file > that uses the usual printdll command line to map the upstairs printer. > > However when I log onto the relevant test PC, the printer doesn't map. I > get no error messages, but I don't get a printer either. > > Is it not possible to execute my usual user config OU scripts AND this new > Upstairs PC script? > > I also tried putting my new script file in the Startup part of Computer > Config > Windows Comp of my Upstairs OU, but this also didn't make a diff. > > NOTE: I have done gpupdate every time I've tried the above. > > Am I doing something daft? Logon scripts run for all users in the OU the GPO applies to, no matter what computer they logon into. Startup scripts run when the computer starts, before there is any user. A solution I have used is to connect to printers in a logon script according to the group the computer is a member of. You can create an Upstairs computer group, for example. In a logon script that runs for all users connect to the printer only if the computer is a member of this group. For example (assuming all clients are Windows 2000 or above): ============ Set objNetwork = CreateObject("Wscript.Network") ' Bind to the local computer object Set objSysInfo = CreateObject("ADSystemInfo") Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName) ' Bind to the group to check for membership. Set objGroup1 = GetObject("LDAP://cn=Upstairs,ou=Sales,ou=West,dc=MyDomain,dc=com") ' Check for membership. If (objGroup1.IsMember(objComputer.AdsPath) = True) Then objNetwork.AddWindowsPrinterConnection "\\PrintServer\HPLaser2" objNetwork.SetDefaultPrinter "\\PrintServer\HPLaser2" End If ========== This assumes the computers don't move without your knowledge. You can also use objSysInfo.SiteName to map printers according to AD site. And there are ways to determine the ip subnet as well. I like computer group membership because it can be managed independently. If you have many printers (and groups), it would make more sense to enumerate the groups a computer is a member of, rather than binding to so many groups. In this case, the code could be similar to: ============== Set objNetwork = CreateObject("Wscript.Network") ' Bind to the local computer object Set objSysInfo = CreateObject("ADSystemInfo") Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName) ' Retrieve direct group memberships. ' Trap the error if there are no groups. On Error Resume Next arrGroups = objComputer.GetEx("memberOf") If (Err.Number <> 0) Then On Error GoTo 0 ' Computer is a member of at least one group (beside "primary"). For Each strGroup In arrGroups Select Case strGroup Case "cn=Upstairs,ou=Sales,ou=West,dc=MyDomain,dc=com" objNetwork.AddWindowsPrinterConnection "\\PrintServer\HPLaser2" objNetwork.SetDefaultPrinter "\\PrintServer\HPLaser2" Case "cn=Floor1,ou=Sales,ou=West,dc=MyDomain,dc=com" objNetwork.AddWindowsPrinterConnection "\\PrintServer\HPLaser3" objNetwork.SetDefaultPrinter "\\PrintServer\HPLaser3" Case "cn=Floor2,ou=Sales,ou=West,dc=MyDomain,dc=com" objNetwork.AddWindowsPrinterConnection "\\PrintServer\HPLaser4" objNetwork.SetDefaultPrinter "\\PrintServer\HPLaser4" End Select Next End If On Error GoTo 0 -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net --
Recommended Posts