Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move computer object according to IP address

Status
Not open for further replies.

purepest

Technical User
Jun 22, 2004
118
GB
Hi

I am looking for a way to originise the workstations, in one of the domains that I help administer, into the correct OUs.

My initial thought was to use scripting. The office is split into office blocks and IP addresses are assigned according to office block number. Our AD OU structure reflects the office block numbers and so does our DHCP allocation.

So, the script would happen during login, capture the IP address and move the machine to the correct OU. Pretty straight forward logic to it. The only problem is that I wouldn't know how to get the IP address of the machine and then check what scope it fits into, then apply the computer move.

I already have a script that will move computers, I just need the IP address bit.

Can anyone help?

Also, if there already any apps that do this I would be interested in them as well.

Thanks a lot
Colin
 
You might want to look into WMI and the Win32_NetworkAdapterConfiguration class, however I think that the logging on user has to have local administrative rights on their PC for this to work, though I may be wrong.

Otherwise, you could try executing the batch command
Code:
ipconfig /all | find /i "ip address"
and parse this in your VB script.

Note that if your PC has multiple IP addresses for any reason, all of them will be listed here so you may have to pick out the appropriate one depending upon the ranges set by the different office blocks.

Any help?
 
Also, if you're expecting the move to happen, the logging on user will have to have rights to move the computer accounts into the appropriate OU, unless you're running a script with elevated priviledges, which is unadvisable, I think....

If you have a list of your machines, you could (slow as it may be) script a pinging of them, capture the stdout, searchc for the IP address, and move the accounts based on that...
 
if you are using AD why not use your already setup AD Sites to put the machines into? this will keep things 'standard'. you can get the machine to return its current AD Site it is assigned to, log it centrally then have your move script move them into OU's which reflects an AD site?
with either the ipaddress or AD Site (as they are both explicitly linked) you will find a few machines will get assigned to funny locations, if the machines are laptops for instance and have moved to a different location on a temp basis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top