Logon Script - map printers based on location

Depending on which DC users logon from (they are in different locations on different subnets, of course)....
can I map printers based on where users logon location?

If I'm in LA, map LA printers
If I'm in NYC, map NYC printers.  I don't want them getting printer connections and then printing to the mystery printer cross country LOL

Thanks
OnsiteSupportAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

beechy_Commented:
If your servers are 2003 R2 or later you can use group policy to deploy printers and set the policies on your site objects to deploy different printers to different locations.

http://www.windowsnetworking.com/articles_tutorials/Deploying-Printers-Group-Policy-Windows-R2.html
0
gemartiCommented:
First you'll have to make sure that your administrators in LA and NYC grant the user permission the the shared resource.

A little more involved that but I think I've covered all you need:
1. Get IP address of machine
2. Determine Location
3. Check if printer is already referenced on the machine and if not install it
4. Set the printer as default printer

You'll have to do a little reading; I didn't want to plagiarize some one else's work so links to different scripts are within the script posted below.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Your script will have to do the following:

//Get the IP address of the machine the user is logging into the network with:

DIM IPLocation

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set IPConfigSet = objWMIService.ExecQuery _

    ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
 
For Each IPConfig in IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then

        For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)

            WScript.Echo IPConfig.IPAddress(i)

        //Determine if IP address in in LA or NYC
 //Convert IPConfig.IPAddress(i) to Binary  SEE HERE: http://www.indented.co.uk/index.php/2008/10/21/vbscript-subnet-math/

        if BinaryIP > NYCBinaryIPS and < NYCBinaryIPS then
       
          IPLocation = NYC
        else
     
         IPLocation = LA
        end if
 
           Select Case IPLocation
         
           Case LA
               //Check if LA printer is already installed If not install it.
               //See Here: http://www.tek-tips.com/viewthread.cfm?qid=551578&page=1
               //Set as default printer
              //See Here: http://www.computerperformance.co.uk/Logon/LogonScript_Printer_Bonus.htm
            Case NYC
               //Check if NYC Printer is already installed if not install it.
              //See Here: http://www.tek-tips.com/viewthread.cfm?qid=551578&page=1
              //Set as default printer
              //See Here
           
          End Select
        Next
    End If
Next



0
greg wardSystems EngineerCommented:
Or you could use this

Option Explicit
Dim objPrinters, objShell, objNetwork, strUNCPrinter1, strUNCPrinter2
 
ON ERROR RESUME NEXT
 
Set objPrinters = WScript.CreateObject("WScript.Network")
Set objShell = WScript.CreateObject("WScript.Shell")
 
 
strUNCPrinter1 = "\\server\printer"
strUNCPrinter2 = "\\server\printer"

Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection strUNCPrinter1
objNetwork.SetDefaultPrinter strUNCPrinter1
 
WScript.Quit
 
copy the file using unc to the all users start up folder and everyone gets the right printer and it gets a default one too.
 
Greg
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

OnsiteSupportAuthor Commented:
Greg-
what is calculating which printer they should get?
0
greg wardSystems EngineerCommented:
strUNCPrinter1 = "\\server\printer"
change to
strUNCPrinter1 = "printserver\printershare"
Greg
 
0
OnsiteSupportAuthor Commented:
I've left out an important piece in the description.  Users from NYC visit LA and want to logon, get their drive mappings, print to the local printers.

Deepdraw....I like your concept, except how will I deploy the VB script to the correct location based on their locale?...it can't be based on OU membership.

Can I get the Logon server name when they logon?

Many thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
maco008Commented:
Have you tried using Group Policy preferences?  You can do a target by IP Address range and you can also set the default printer based on their location (through IP address).
Assuming that NYC and LA branches have different subnets (should be).

Check this out.

http://www.grouppolicy.biz/tag/printer/

For group policy preferences, you can check out this link

http://www.windowsnetworking.com/articles_tutorials/Group-Policy-Preferences-Get-Them-Running-Today.html
0
OnsiteSupportAuthor Commented:
maco-
Looks like this is only available on Windows Server 2008...am I correct?
0
maco008Commented:
nope. u only need vista or higher OS version to manage it and see the option. domain can be 2k3 and u just need to install the extensions on clients lower than vista.
0
OnsiteSupportAuthor Commented:
Maco....extensions...can you point me to the right documentation for this piece?
0
maco008Commented:
http://www.windowsnetworking.com/articles_tutorials/Group-Policy-Preferences-Get-Them-Running-Today.html

This article is pretty good and explains everything.  As what he said (never tried though) you can even use this on a 2k domain.  Just check the part "Getting the CSE Installed Correctly" for instructions.   You can download the KB links and install it manually or use WSUS to install it automatically (just search group policy extension).

First you need to have at least a vista workstation, you don't need to have a 2k8 server to do this, then install GPMC on your vista or windows 7.  You should be able to see "Preferences" through vista/windows 7 gpmc.

Here's the article on how to install GPMC/RSAT on vista.
http://www.windowsecurity.com/articles/Installing-Using-Remote-Server-Administration-Tools-RSAT-Vista.html
0
greg wardSystems EngineerCommented:
Hi
This script just sits on the machine in the all users start up and does not require domain membership.
 
Greg
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Server OS

From novice to tech pro — start learning today.