Link to home
Start Free TrialLog in
Avatar of logic0004
logic0004

asked on

Script to assign computer names based on MAC address

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.
Avatar of yotamsher
yotamsher

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
Avatar of logic0004

ASKER

Commercial products like what ??
 
can u post some links for those kind of products ?
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
ASKER CERTIFIED SOLUTION
Avatar of fostejo
fostejo

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
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....
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,
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.