Name computers by using serial numbers

I am a beginner in Power shell and I am trying to automatically name the computer from a .cvs file.

What I have is a column that says serial number & one that says computer name.

What I want the end result to be is for it to find the serial number of that computer and look in the Rename.csv file for that serial and give it the name that corresponds with that serial number. can some one give me an example of how to write that in power shell?

Any help will greatly appreciated.

James I.

 
May 21st, 2015 2:53pm

I am a beginner in Power shell and I am trying to automatically name the computer from a .cvs file.

What I have is a column that says serial number & one that says computer name.

What I want the end result to be is for it to find the serial number of that computer and look in the Rename.csv file for that serial and give it the name that corresponds with that serial number. can some one give me an example of how to write that in power shell?

Any help will greatly appreciated.

James I.

 

Are your computers in domain?   
And btw, naming computers based on serial numbers is terrible imho -.-   Ive never seen it

(Get-WmiObject Win32_ComputerSystem).Rename('yourserialnumber')
or 
Rename-computer (PS v3.0)


Free Windows Admin Tool Kit Click here and download it now
May 21st, 2015 4:06pm

No they are not on the domain yet. And I am not naming them the serial # I just want to use the serial # so it knows what to name it from the csv file.

Thanks for the reply

May 21st, 2015 4:21pm

How are you going to find the computers if they are not in a domain?  What mechanism lets you discover the computers.  Are they in a dedicated DHCP scope?  Are they registered to an Internet domain.  Are they on an IP subnet?

You need to solve these problems to do what you are asking.

If you are looking for just a local solution then you can get the serial number this way:

WMIC OS get serialnumber

Now you can just match it.

If you want to look it up then you need the file:

$sn=(gwmi win32_operatingsystem).Serialnumber
$computername=Import-Csv systems.csv | ?{$_.serialnumber -eq $sn}

Free Windows Admin Tool Kit Click here and download it now
May 21st, 2015 4:43pm

I am using WDS to deploy the image to the computers then have it name them. eventually get it to join the domain but for now I have a script that does that and a few other things.

I will play with you suggestions and see if I can make it happen and will let you know how it goes. 

May 21st, 2015 5:00pm

Look at the WDS configuration documents. There are macros and events that can retrieve the name by matching to a file or database. Post future issues in the Windows deployment forum.  They will show you the best ways to do this with WDS.

Free Windows Admin Tool Kit Click here and download it now
May 21st, 2015 5:08pm

Thanks I put it here because since I was using power shell I figure it was the right place for it Sorry I will go there from now on
May 21st, 2015 5:11pm

Thanks I put it here because since I was using power shell I figure it was the right place for it Sorry I will go there from now on

Not a problem but the deployment forum is likely to be more global and have more options. If you have a script component and are having issue then her is a possible place to post.
Free Windows Admin Tool Kit Click here and download it now
May 21st, 2015 5:31pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics