Here's a portion of a PowerShell script we use:
$Serial = Get-WMIObject -Class Win32_Bios
$CompSystem = Get-WMIObject -Class Win32_ComputerSystem
$Model = $CompSystem.Model
$Manufacturer = $Serial.Manufacturer
if ($Manufacturer -like "*Dell*") {$Manufacturer="Dell"}
if ($Manufacturer -like "*Hewlett*") {$Manufacturer="HP"}
$ServiceTag = $Serial.SerialNumber
#Renaming PC
$CurrentName = $env:COMPUTERNAME
if ($CurrentName -match $ServiceTag) {}
else { Rename-Computer -computername $CurrentName -newname $ServiceTag }
From: [email protected] [mailto:[email protected]] On
Behalf Of Gavin Wilby
Sent: Wednesday, January 20, 2016 8:19 AM
To: '[email protected]' <[email protected]>
Subject: [NTSysADM] Rename PC batch/ powershell/ VB
Hi All,
I promise that I have Google searched this but unable to find a easy answer.
I want a script to run after a machine is cloned that will rename the machine
account to the serial number.
I know I can get this by using wmic bios get serialnumber, ideally, prefixed
with thin-, so thin-012345 for example.
I can put the script to be called on the runonce reg key on next boot, but
cannot get it formatted so it works correctly.
Could anyone assist please?
Gavin Wilby
IT Support Engineer
SMP Partners Ltd
Clinch's House, Lord Street,
Douglas, Isle of Man IM99 1RZ
Tel +44 1624 682214
Mob +44 7624 480575
[email protected]<mailto:[email protected]>
www.smppartners.com<http://www.smppartners.com/>
A member of the SMP Partners Group of Companies
SMP Partners Limited, SMP Trustees Limited and SMP Fund Services Limited are
licensed by the Isle of Man Financial Services Authority. SMP Accounting & Tax
Limited is a member of the ICAEW Practice Assurance Scheme.
SMP Partners Limited registered in the Isle of Man, Company Registration No:
000908V
Directors: M.W. Denton, M.J. Derbyshire, S.E McGowan, O. Peck, J.J. Scott, S.J.
Turner
SMP Trustees Limited registered in the Isle of Man, Company Registration No:
068396C
Directors: A.C. Baggesen, J.M. Cubbon, M.W. Denton, K.M. Goldie, O Peck, J.
Watterson
SMP Fund Services Limited registered in the Isle of Man, Company Registration
No: 120288C
Directors: V. Campbell, R.K. Corkill, M.W. Denton, D.A. Manser, S.E McGowan,
J.J. Scott
SMP Accounting & Tax Limited registered in the Isle of Man, Company
Registration No: 001316V
Directors: I.F. Begley, A.J. Dowling, P. Duchars, J.J. Scott, S.J. Turner
SMP Capital Markets Limited registered in the Isle of Man, Company Registration
No: 002438V
Directors: M.W. Denton, M.J. Derbyshire, D.F Hudson, S.E McGowan, O. Peck, J.J.
Scott.
SMP Partners Limited, SMP Trustees Limited, SMP Fund Services Limited, SMP
Accounting & Tax Limited and SMP Capital Markets Limited are members of the SMP
Partners Group of Companies.
This email is confidential and is subject to disclaimers. Details can be found
at: http://www.smppartners.com/disclaimer.html
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________