OnsiteSupport
asked on
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
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
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=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfig uration Where IPEnabled=TRUE")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddres s) 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
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=imper
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfig
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress)
For i=LBound(IPConfig.IPAddres
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
Or you could use this
Option Explicit
Dim objPrinters, objShell, objNetwork, strUNCPrinter1, strUNCPrinter2
ON ERROR RESUME NEXT
Set objPrinters = WScript.CreateObject("WScr ipt.Networ k")
Set objShell = WScript.CreateObject("WScr ipt.Shell" )
strUNCPrinter1 = "\\server\printer"
strUNCPrinter2 = "\\server\printer"
Set objNetwork = CreateObject("WScript.Netw ork")
objNetwork.AddWindowsPrint erConnecti on strUNCPrinter1
objNetwork.SetDefaultPrint er 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
Option Explicit
Dim objPrinters, objShell, objNetwork, strUNCPrinter1, strUNCPrinter2
ON ERROR RESUME NEXT
Set objPrinters = WScript.CreateObject("WScr
Set objShell = WScript.CreateObject("WScr
strUNCPrinter1 = "\\server\printer"
strUNCPrinter2 = "\\server\printer"
Set objNetwork = CreateObject("WScript.Netw
objNetwork.AddWindowsPrint
objNetwork.SetDefaultPrint
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
ASKER
Greg-
what is calculating which printer they should get?
what is calculating which printer they should get?
strUNCPrinter1 = "\\server\printer"
change to
strUNCPrinter1 = "printserver\printershare"
Greg
change to
strUNCPrinter1 = "printserver\printershare"
Greg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
maco-
Looks like this is only available on Windows Server 2008...am I correct?
Looks like this is only available on Windows Server 2008...am I correct?
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.
ASKER
Maco....extensions...can you point me to the right documentation for this piece?
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
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
Hi
This script just sits on the machine in the all users start up and does not require domain membership.
Greg
This script just sits on the machine in the all users start up and does not require domain membership.
Greg
http://www.windowsnetworking.com/articles_tutorials/Deploying-Printers-Group-Policy-Windows-R2.html