Solved

Assign printers to users in Active Dir

Posted on 2004-09-15
3
149 Views
Last Modified: 2010-04-13
I have been trying to "push" network printer information to AD users using a login script.  To do that, I would remove all printers and then add them back, but am having issues.  Before I spend more time on this, I thought I would check if there is a way to push network printers to a universal AD group's workstation, so they can use a local printer or use a networked printer for the workgroup.

Anyone have instructions on doing this?

Thanks.

Steve
0
Comment
Question by:smeek
3 Comments
 
LVL 83

Expert Comment

by:oBdA
ID: 12078339
If the printer mapping can be determined by global group membership as well (ifmember doesn't work with universal groups), the easiest solution is the logon script and con2prt.exe (still works fine on XP).
Example:

====8<----[logon.cmd]----
@echo off
:: *** Delete all mapped printers:
con2prt.exe /f
:: *** Map the printers according to group membership:
ifmember.exe YourDomain\Printer01Group
if not errorlevel 1 goto EndPrinter01Group
con2prt.exe /c \\PrintServer\Printer01
:EndPrinter01Group

ifmember.exe YourDomain\Printer02Group
if not errorlevel 1 goto EndPrinter02Group
con2prt.exe /c \\PrintServer\Printer02
:EndPrinter02Group
====8<----[logon.cmd]----

How to Use Con2prt.exe to Connect to a Network Printer
http://support.microsoft.com/?kbid=181663

Zero Administration Kit
http://www.microsoft.com/ntworkstation/downloads/Recommended/Featured/NTZAK.asp

Resource Kits Free Tool Downloads: Ifmember.exe
http://www.microsoft.com/windows2000/techinfo/reskit/tools/new/ifmember-o.asp
0
 
LVL 8

Accepted Solution

by:
smeek earned 0 total points
ID: 12084997
I have written a script that works OK.  The issue is that I have it remove printers first (which causes problems with the ever changing users who add local printers).  I tried to avoid removing printers but then had problems with the script or errors that showed to users.

The script excerpt is below.

Steve

''''''''''  ''''''''''

Set oPrinters = oNet.EnumPrinterConnections
         For i = 0 to oPrinters.Count - 1 Step 2
            oNet.RemovePrinterConnection oPrinters.Item(i+1), true, true
         Next

        If Err.Number <> 0 Then
          Err.Clear
        End If



'''''''''' ADD PRINTERS '''''''''''''

        Set objUser = GetObject("WinNT://DOMAIN/" & sUser & ",user")

        For Each grp In objUser.Groups

           Select Case grp.Name
       
              Case "Accounting"
              oNet.AddWindowsPrinterConnection "\\lisa\lenny", "Lenny- Samsung ML-1450 Series PCL 6"

            Case "Legal"
              oNet.AddWindowsPrinterConnection "\\lisa\lenny", "Lenny- Samsung ML-1450 Series PCL 6"

              Case "Everyone"
              oNet.AddWindowsPrinterConnection "\\lisa\carl", "Carl- Samsung ML-1450 Series PCL 6"

              Case "Recon"
              oNet.AddWindowsPrinterConnection "\\lisa\krusty", "Krusty- HP LaserJet 4 Plus"
       
              Case "Production"
              oNet.AddWindowsPrinterConnection "\\lisa\milhouse", "Milhouse- HP LaserJet 4300 PCL 6"

              Case Else
'                wsh.echo  "No Mappings for " & grp.Name

        End Select
      
      Next

        If Err.Number <> 0 Then
          MsgBox "Error Mapping Printers: " & Err.Description
          Err.Clear
        End If



'''''''''' DONE ''''''''''
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
A procedure for exporting installed hotfix details of remote computers using powershell
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now