Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 853
  • Last Modified:

Active Directory LOGIN script for ALL USERS on only SOME MACHINES

I am trying to figure out how to run a small script to add a printer when ANY user logs into ONLY LAB computers. The script works if I apply the group policy to all users but it adds the printer to every computer on the network. If I try to restrict by computer or group the script doesn't run. Any ideas?
0
ocacadmin
Asked:
ocacadmin
  • 2
1 Solution
 
2PiFLCommented:
Create an OU for the lab computers, move the lab computers to this OU and apply the GPO to this OU.
0
 
mdefalcoCommented:
You should have the IP addresses of those computers and then you can add them to your script.

First go to this webpage, it will show you how to get the ip address of the machine you are logging into;

http://www.codeproject.com/vbscript/ipaddress.asp

This creates a variable called GetIPAddress, you can now use this in your code. How many computers are in that lab, and are their ips static, if not you should set them to static, or give them a dhcp reservation.

You can now comare the ips in the lab to the current loggen in user ip and tell it to install only on the machines that do not fit this ip.

If they are in a different subnet all together, then you can set them up in AD as a seperate subnet and then add that subnet to the GP, alone. I have done this before but a long time ago, if you need it this way I can help you with that.
0
 
ocacadminAuthor Commented:
I figured out a better solution to my problem:

The reason I was trying to do this is because I thought I could not add printers at the machine level rather than just added printers to user profiles.

You can in fact add printers to Machines, but only at the command line like so:

rundll32 printui.dll,PrintUIEntry /ga /q /n\\server.name\printer-name

The ga switch adds a "per machine printer" that is available to every user that can login to the machine.

After that it just a matter of adding this line to a startup script either through Active Directory or some other means.


rundll32 printui.dll,PrintUIEntry /ga /q /n\\server.name\printer-name

Open in new window

0
 
mdefalcoCommented:
Very cool, thanks for posting that. I think I may have a use for it too,

~ Jim
0

Featured Post

Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now