Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Computer Rename using Win32_Baseboard Serial number

116 views
Skip to first unread message

Mark

unread,
Nov 6, 2009, 12:08:02 AM11/6/09
to
Hey All,

I am new to powershell and I am trying to rename my Windows 7 laptop using
powershell. I have the following script and it's not working. Does anyone
know where I am going wrong? I wish to rename the computer using the
SerialNumber from W32_Baseboard.

Function Rename-ComputerName ([string]$NewComputerName){

$ComputerName = Get-WmiObject -Class Win32_BaseBoard | select SerialNumber
$ComputerInfo = Get-WmiObject -Class Win32_computersystem
$ComputerInfo.rename("$ComputerName")

}
Restart-Computer

Thanks in advance.

Regards,

Mark

Martin Zugec

unread,
Nov 6, 2009, 1:40:14 AM11/6/09
to
Hi Mark,

don't have a change to try it, however can you try following?

Function Rename-ComputerName ([string]$NewComputerName){

[String]$ComputerName = Get-WmiObject -Class Win32_BaseBoard | select

SerialNumber
$ComputerInfo = Get-WmiObject -Class Win32_computersystem
$ComputerInfo.rename("$ComputerName")

}
Restart-Computer

Martin

"Mark" <Ma...@discussions.microsoft.com> wrote in message
news:B19AA1E0-409C-4963...@microsoft.com...

RichS [MVP]

unread,
Nov 6, 2009, 8:19:02 AM11/6/09
to
One thing to check is that the serial number is actually returned on your
machine. On my laptop it isn't returned

PS> Get-WmiObject -Class Win32_BaseBoard


Manufacturer : Wistron
Model :
Name : Base Board
SerialNumber :
SKU :
Product : 303C


--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk

Ant

unread,
Nov 6, 2009, 9:24:01 AM11/6/09
to

Mark,

Try going after - Win32_BIOS | Select SerialNumber

Ant

Mark

unread,
Nov 8, 2009, 3:39:01 PM11/8/09
to

Thanks. It doesnt work. If I try the Rename-ComputerName alone the term isn't
recognized. Any ideas?

Mark

unread,
Nov 8, 2009, 3:36:02 PM11/8/09
to

It certainly does. One of those Lenovo models that has the serial number in
the baseboard not the bios.

Larry__Weiss

unread,
Nov 8, 2009, 3:59:54 PM11/8/09
to

I'm not seeing where

1) parameter $NewComputerName is used anywhere inside function
Rename-ComputerName
2) a call to function Rename-ComputerName with a specific value for parameter
$NewComputerName is made before the Restart-Computer command is executed

- Larry

0 new messages