Link to home
Start Free TrialLog in
Avatar of ebizdatacom
ebizdatacom

asked on

VBScript: Map Printers based on computer group in Active Directory

I have a site that has several areas (ie front desk, reception, billing, nurses station,) and each area has a printer.  I have a script that I'm using that runs on the local W2K and XP workstations and maps specified printers and drive mappings.  I would like to improve on this though and have a script that maps a printer based on computer membership.  I'm very new to scripting and have pieced together the one I use from other folks kind examples online.  I have inputed part of my script below to give an idea as to what I'm looking for and how things are running now.

Currently I have something like...

Set objWSHNetwork = CreateObject("WScript.Network") 'create network object
strConnectString = "\\server\CanonS82"
strResult = objWSHNetwork.AddWindowsPrinterConnection(strConnectString)

I'd like an example script given what I have above thats something like this in concept...

If member of computergroup (front desk) then
Set objWSHNetwork = CreateObject("WScript.Network") 'create network object
strConnectString = "\\web_development\CanonS82"
strResult = objWSHNetwork.AddWindowsPrinterConnection(strConnectString)
end if

If member of computergroup (back office) then
Set objWSHNetwork = CreateObject("WScript.Network") 'create network object
strConnectString = "\\Server\HPLJ6"
strResult = objWSHNetwork.AddWindowsPrinterConnection(strConnectString)

Thank you in advance for all of your help.  I've learned a lot already, and am hoping that I can get an understandable answer to this problem.

Thank you
Avatar of TheCleaner
TheCleaner
Flag of United States of America image

This is really something to be done based on the Location field

See here:

http://technet2.microsoft.com/WindowsServer/en/Library/f33624bc-7518-4c2d-8f73-8a3d4571dae91033.mspx


Hello,
If you wanted to try it with vbscript review this webpage.
http://www.rlmueller.net/freecode1.htm

It contains scripts to check for group membership of users or computers.
There are several there so make sure you find the one that suits your needs the best.

Once you find one let us know if you need help placing it into your existing code.
ASKER CERTIFIED SOLUTION
Avatar of Kevin Hays
Kevin Hays
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial