|
|
![]() |
|
|
Top | #1 |
|
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67 |
How can i assign printers that are relevant to where the user is located at a certain department. I only have one PC running Windows Server 2003 Enterprise, would I need another? thnx |
|
|
|
|
|
Top | #2 |
|
Bow Down to the King
Joined: April 2002
Location: New York
Posts: 13,312
Reputation: 4090
Power: 297 |
Are the users logging in on the same computer each time or are they moving around? Command scripting would work for the first, but not for the second because Active Directory doesn't know where the computer is technically located.
|
|
|
|
|
|
Top | #3 |
|
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67 |
They would be logging into many machines as each department has say 5 clients for that department.
e.g. A user logs on (to any of the 5) at the English department and only have a choice to use printers in the English department. While a user doing the same thing in the ICT department only sees ICT department printers. Would creating a script under Computer Configuration do the trick, (and bin the ones I have set that show them all printers). So the script is run to all who log in to those particular machines? But as to how to apply the script to an actual Computer I'm not sure. hope thats clear |
|
|
|
|
|
Top | #4 |
|
Bow Down to the King
Joined: April 2002
Location: New York
Posts: 13,312
Reputation: 4090
Power: 297 |
I didn't think of that idea. Put each of those computers into a different OU and you should be good to go.
|
|
|
|
|
|
Top | #5 |
|
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67 |
Originally Posted by madmatt
It didn't come off unfortunately. It ran the Computer Settings on user logon but nothing came off, not even an error.Surely though it should have worked.
Applying a startup script to a Computer to connect certain printers, it makes sense lol. Did you have another idea? |
|
|
|
|
|
Top | #6 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168 |
From what I understand, you want whoever signs into an English dept computer to have the english dept printers connected and simlilar setups for other dept.
You can actually do a couple things: 1) Put computers into seperate dept based OU's 2) Put computers into seperate dept base groups. In either case, you can use either a computer or user loginscript to map the printers. Computer startup may be a bit iffy since the computer may not have connected/authenticated/set up the secure session to the domain by the time the startup script runs (yes, computers authenticate to the domain!). Depending on how your group policies are set to process user login scripts, you might have the same problems with user login scripts since it is technically possible to set policies to process logins before the computer is fully "up" and on the domain. Trust me, it took me a long time to track down why our login scripts weren't properly pulling domain info during login until I traced it down to this. My advice would be to set your user login scripts to check either condition above on the computer account (either computer OU membership or computer group memberships) and map your printers accordingly. Again, you need some scripting advice, lets start with what you have and go from there. |
|
|
|
|
|
Top | #7 |
|
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67 |
This is my current script as is:
Set WshNetwork = CreateObject("WScript.Network") WshNetwork.AddWindowsPrinterConnection "\\JONNYSERV1\HP LaserJet 4100 Series PS" WshNetwork.SetDefaultPrinter "\\JONNYSERV1\HP LaserJet 4100 Series PS" |
|
|
|
|
|
Top | #8 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168 |
As I think about it, a computer script won't work. When you connect/map a printer, it is tied to the user profile.. since a user profile isn't loaded when a computer startup script runs, the printer has no profile to connect to.
You could, in theory, try to map a printer and copy that profile to the default profile. This will allow any new profile that is created to already have that printer connected. For existing users, you could either map them manually, or delete their profile and force them to generate a new one from the default profile (I don't recommend deleting existing profiles..). The downside of using the profile method, is anytime you add/replace/move a computer to a department, you'll have to remember to set this up each file. A script solution is still more ideal to me for this reason. Since a computer startup script won't work, you'll have to do it during the user login script. You still have to choices depending on your needs: 1) Put computers into seperate OU's and check the computer OU during the login script and map printers accordingly. 2) Put computers into groups and check computer group membership during the login script and map printers accordingly. Checking the OU is quicker/faster to script, but some environments don't allow/don't want computer's in OU's based on location.. thus checking group membership would be used. If you're workplace doesn't mind seperate OU's for each location/dept for the computer accounts, which it sounds like your location, then use the OU. Code:
'returns the LDAP Path (distinguished name) of the computer account
set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
You would then search the LDAP string for your OU and using either a case statement or if/then's map your printers accordingly. Searching the LDAP string can be done a number of ways depending on the complexity of your LDAP path and if you use commas in OU names, etc. If it's fairly simple (ie: no nested OU's, etc..) Code:
'find where the OU section starts in the LDAP Path
intStart=InStr(0,strComputerDN,"OU=")
'if the OU section exists, process the ou name
if intStart <> 0 then
intEnd=InStr(intStart,strComputerDN,",")
'extract just the ou= portion
strOU = mid(strComputerDN,intStart,intEnd)
Set objNetwork= CreateObject("WScript.Network")
'depending on which ou, map printers (converted ou string to all lower case)
select case lcase(strOU)
case "ou=english"
objNetwork.AddWindowsPrinterConnect "<printer path>"
objNetwork.AddWindowsPrinterConnect "<printer path2>"
objNewwork.SetDefaultPrinter "<defaultPritnerPath>"
case "ou=math"
<map printers for computers in math dept.>
end select
end if
disclaimer - the code above is for example purposes only. It is only a skeleton/framework and really needs some error checking and other controls put in before being considered for production use. |
|
|
|
|
|
Top | #9 |
|
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67 |
OK, I decided to try this out on my test box (Server 2003 R2)
OU's: -PUBLIC (2 two clients- pub1, pub2) -NEO (1 client- neo-1) using the following: Code:
set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
intStart=InStr(0,strComputerDN,"PUBLIC=")
if intStart <> 0 then
intEnd=InStr(intStart,strComputerDN,",")
strOU = mid(strComputerDN,intStart,intEnd)
Set objNetwork= CreateObject("WScript.Network")
select case lcase(strOU)
case "ou=PUBLIC"
objNetwork.AddWindowsPrinterConnect "\\JONNYSERV\HP 2000C 1"
objNetwork.AddWindowsPrinterConnect "\\JONNYSERV\HP 2000C 2"
objNewwork.SetDefaultPrinter "\\JONNYSERV\HP 2000C 1"
case "ou=NEO"
objNetwork.AddWindowsPrinterConnect "\\JONNYSERV\HP 2000C 3"
objNewwork.SetDefaultPrinter "\\JONNYSERV\HP 2000C 3"
end select
end if
Line: 3 Char: 1 Error: Invalid procedure call or argument: 'InStr' Code: 800A0005 Source: Microsoft VBScript Runtime Error Whats wrong? I know I'm such a pain on scripts |
|
|
|
|
|
Top | #10 |
|
Bow Down to the King
Joined: April 2002
Location: New York
Posts: 13,312
Reputation: 4090
Power: 297 |
Try OU=PUBLIC
|
|
|
|
|
|
Top | #11 |
|
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67 |
|
|
|
|
|
|
Top | #12 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168 |
as a quick test, after you pull the objSysInfo.Computername , do a:
"wscript.echo strComputerDN" and comment out the rest of the script. Make sure it is returning a valid value |
|
|
|
|
|
Top | #13 |
|
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67 |
Originally Posted by fitz
Like this?
Code:
set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
"wscript.echo strComputerDN"
intStart=InStr(0,strComputerDN,"ou=PUBLIC")
if intStart <> 0 then
intEnd=InStr(intStart,strComputerDN,",")
strOU = mid(strComputerDN,intStart,intEnd)
Set objNetwork= CreateObject("WScript.Network")
select case lcase(strOU)
case "ou=PUBLIC"
objNetwork.AddWindowsPrinterConnect "\\JONNYSERV\HP 2000C 1"
objNetwork.AddWindowsPrinterConnect "\\JONNYSERv\HP 2000C 2"
objNewwork.SetDefaultPrinter "HP 2000C 1"
case "ou=NEO"
objNetwork.AddWindowsPrinterConnect "HP 2000C 3"
objNewwork.SetDefaultPrinter "HP 2000C 3"
end select
end if
|
|
|
|
|
|
Top | #14 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168 |
no.. without quotes around the wscript.echo ... and either delete or comment out the rest of the script
|
|
|
|
|
|
Top | #15 |
|
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67 |
Windows Script Host returned the following:
Code:
CN=PUB1,OU=PUBLIC,DC=TESTSERV,DC=local |
|
|
|
|
|
Top | #16 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168 |
well, let's start with trying to remove the start position so, your code would start like:
Code:
set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = lcase(objSysInfo.ComputerName)
intStart=InStr(strComputerDN,"ou=")
|
|
|
|
|
|
Top | #17 |
|
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67 |
OK, should I execute that or what?
|
|
|
|
|
|
Top | #18 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168 |
that should just be the beginning of the script.. i expect you to do some work and thinking as well..
|
|
|
|
|
|
Top | #19 |
|
OSNN AZN Addict
Joined: March 2004
Posts: 383
Reputation: 10
Power: 103 |
not sure if this work but after sharing the printer, there's this security settings where we can set a specifically user to print, manage documents and etc.
|
|
|
|
|
|
Top | #20 |
|
IT guy
Joined: March 2007
Location: Chicago
Posts: 48
Reputation: 20
Power: 64 |
I tried this command as a login script but I received an error:
rundll32 printui.dll,PrintUIEntry /ga /in /n\\hubdc1\AcctLJ2200 /y Anything wrong with this command? Sorry to threadjack! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Create and assign common domain download storage | philabraham | Windows Server Systems | 1 | December 12th, 2006 2:00pm |
| assign dhcp addresses based on OU membership | fimchick | Windows Desktop Systems | 5 | April 6th, 2006 10:06pm |
| assign keys on keyboard | Silvio | Desktop Customisation | 4 | May 5th, 2003 10:08pm |
| Name the location... | pc_tek | Green Room | 21 | May 25th, 2002 3:23pm |
| How to assign specific User profiles with gpedit ? | BoaVista | Desktop Customisation | 1 | February 2nd, 2002 6:12pm |