Solved

Script to assign computer names based on MAC address

Posted on 2006-07-02
7
1,191 Views
Last Modified: 2008-01-09
Hi all,

I want to assign computer names using the MAC addresses. The company has around 500 computers and after ghosting, its a big time consuming task to assign computer name manually to each system. So, is there a way that we have list of MAC address -- computer names and the script runs and finds the local MAC address and then assigns the related computer name to the system.

I need to whole code if its possible. The computers are running WinXP SP2. May be it can be done using VB.net but i m not an expert programmer...

Any help would be appreciated.
0
Comment
Question by:logic0004
  • 3
  • 2
  • 2
7 Comments
 
LVL 7

Expert Comment

by:yotamsher
Comment Utility
Hey logic0004

from Your question it seems to me that your company need something like Microsoft System Management Server.

but being specific about programming, here is my answer split into two parts:

1) the following script aquires the MAC address(s)
just put it in a .vbs file and run it

Set NetAdapterSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select *

from Win32_NetworkAdapter")
for each NetAdapter in NetAdapterSet
   wscript.echo NetAdapter.MACAddress
next

2) The following script from Microsoft site (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_start_page.asp)
is supposed to rename the computer ( I did not try it)

Name = "name"
Password = "password"
Username = "username"

Set objWMIService = GetObject("Winmgmts:root\cimv2")

' Call always gets only one Win32_ComputerSystem object.
For Each objComputer in _
    objWMIService.InstancesOf("Win32_ComputerSystem")

        Return = objComputer.rename(Name,Password,User)
        If Return <> 0 Then
           WScript.Echo "Rename failed. Error = " & Err.Number
        Else
           WScript.Echo "Rename succeeded." & _
               " Reboot for new name to go into effect"
        End If
Next

again, In the scale you are talking about I would consider a comercial product

good luck

Yotam
0
 
LVL 2

Author Comment

by:logic0004
Comment Utility
Commercial products like what ??
 
can u post some links for those kind of products ?
0
 
LVL 7

Expert Comment

by:yotamsher
Comment Utility
I think "Microsoft SMS" http://www.microsoft.com/smserver/default.mspx
can do what you need.
but hey, I'm a programmer not a real IT expert
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 10

Accepted Solution

by:
fostejo earned 500 total points
Comment Utility
logic0004,

Something like WSName.exe available at http://mystuff.clarke.co.nz/wsname.asp may do the trick - it seems pretty comprehensive and is well documented, allowing you to change the computer name via one command line (fired from a VBScript, batch file etc.) by taking into account a wide variety of different attributes including the MAC address.  It can also assign names randomly, and takes into account Domain membership etc.

hope that helps..
0
 
LVL 2

Author Comment

by:logic0004
Comment Utility
Thanks , fostejo for the link.

The stuff up there is very useful and I would appreciate if u can post few more links have cool stuff like that....
0
 
LVL 10

Expert Comment

by:fostejo
Comment Utility
Hi logic0004,

The program mentioned in my previous response is just about the best I've seen for doing the specific task as per your question.

There are probably too many potential links with 'cool stuff' to list (!) - is there anything specific related to your question you're looking for? - I (and others) will then be better placed to direct you accordingly..

cheers,
0
 
LVL 2

Author Comment

by:logic0004
Comment Utility
Actually we are working on another project which includes CISCO routers and switches, and we want to build an interface like a webpage where u enter the MAC address, IP address, port number etc. (depending upon the requirement) for opening that specific port for the specified MAC address.

The basic idea is to connect the webpage to issue commands at the backend to the router. Like the information will go to the database and there must be some form of script or program running which pulls the required information from the database and telnet to the router/switch to the exexute the command on them.

I couldn't find much information yet, any help or link u can provide to do the job would be appreciated.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Fix45 challenge 15 82
Sql how to exclude from a table 3 70
stringclean challenge 26 53
java  and programming certification ? 4 62
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now