bill_lynch
asked on
Map Network printer based on OU
Greetings:
I have the following script:
' VBScript to map two printers from two servers
'
' ************************** ****
Dim multiPrinter, UNCpath1, UNCpath2
UNCpath1 = "\\cnb06\hptrain"
UNCpath2 = "\\cnb06\trainer"
Set multiPrinter = CreateObject("WScript.Netw ork")
multiPrinter.AddWindowsPri nterConnec tion UNCpath1
multiprinter.RemovePrinter Connection UNCpath1
multiPrinter.AddWindowsPri nterConnec tion UNCpath2
multiprinter.SetDefaultPri nter "\\cnb06\trainer"
WScript.Quit
' End of example VBScript
The script works well when I just run it.
However the users that need to run it are not assigned to the OU in which the computers are.
This is a training room. We have a training room OU that has an OU for the computers in it.
The user objects are in another OU, so when I assign it as a User Group policy, it will not map the printer. Any suggestions?
I have the following script:
' VBScript to map two printers from two servers
'
' **************************
Dim multiPrinter, UNCpath1, UNCpath2
UNCpath1 = "\\cnb06\hptrain"
UNCpath2 = "\\cnb06\trainer"
Set multiPrinter = CreateObject("WScript.Netw
multiPrinter.AddWindowsPri
multiprinter.RemovePrinter
multiPrinter.AddWindowsPri
multiprinter.SetDefaultPri
WScript.Quit
' End of example VBScript
The script works well when I just run it.
However the users that need to run it are not assigned to the OU in which the computers are.
This is a training room. We have a training room OU that has an OU for the computers in it.
The user objects are in another OU, so when I assign it as a User Group policy, it will not map the printer. Any suggestions?
in it wasnt clear the script map base on computer ou
ASKER
I only have 1 OU that I need to map printers for so this appears to be over kill?
I just want a simple script, I can assign to the OU Training and have all the computers in that OU be assigned the correct printer.
I just want a simple script, I can assign to the OU Training and have all the computers in that OU be assigned the correct printer.
sorry didn't get the tearm over kill :-)
this is a simple script but here a version that will work for you
and if i under stand correct your ou name is "Training".
edit the printer unc to your detailes you can copy the line how much your want to match your printer you want to map:
objNetwork.AddWindowsPrint erConnecti on "\\PrintServer1\ClientPrin ter"
this is a simple script but here a version that will work for you
and if i under stand correct your ou name is "Training".
edit the printer unc to your detailes you can copy the line how much your want to match your printer you want to map:
objNetwork.AddWindowsPrint
Set objSysInfo = CreateObject("ADSystemInfo")
strName = objSysInfo.ComputerName
arrComputerName = Split(strName, ",")
arrOU = Split(arrComputerName(1), "=")
strComputerOU = arrOU(1)
Set objNetwork = CreateObject("WScript.Network")
Select Case strComputerOU
Case "Training"
objNetwork.AddWindowsPrinterConnection "\\PrintServer1\ClientPrinter"
objNetwork.SetDefaultPrinter "\\PrintServer1\ClientPrinter"
end select
ASKER
OK, I can try this.
What if The OU is a couple of layers down, i.e. \\domain\departments\train ing in the AD structure. Will I need to specify that anywhere? Would I still apply this script to the training OU as a user login script?
What if The OU is a couple of layers down, i.e. \\domain\departments\train
ASKER
Where is this script checking against Active Directory?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I decided not to pursue this.
change the the o name in the case statment to your training ou
you can leave one case and edit it like this
Select Case strComputerOU
Case "training"
objNetwork.AddWindowsPrint
end select
Open in new window