/build/static/layout/Breadcrumb_cap_w.png

Formatting Bios SerialNumber Script Output in PowerShell

Newbie question new to KACE and Powershell,  but I have been searching and reading for a while now and cannot figure out how to format so I only get serial number value from bios.
Using 1st part of script below I get     "Serialnumber  :  1GXBJL1"
where all I want is the    "1GXBJL1"   that I can pass to 2nd part.

# Getting the Serial Number from Bios and Outputting to Defined Variable.
gwmi win32_bios | Format-List serialnumber -OutVariable CN

# Renaming..
Rename-Computer -NewName "$CN" -Restart

Thanks in advance.
Mark


2 Comments   [ + ] Show comments
  • I'm on Mac OS X so I can't test right now but try this for the first line:

    $CN = (gwmi win32_bios).serialnumber - flip1001 7 years ago
  • That did the trick I had tried it outputed only the serial number as a clean value. Thanks - mark.adams 7 years ago

Answers (1)

Posted by: mark.adams 7 years ago
White Belt
0
That did the trick. It pulled the Serial number out as a value. That value was then used to rename computer. All of our Pc's are Dell's and they already have a unique serial number in bios so we use that for our computer names. 
Here is clean copy of final script.

Answered by 


I was just trying to clean up a final answer for others to read

  • # Getting the Serial Number from Bios and Outputting to Defined Variable.
$CN = (gwmi win32_bios).serialnumber
# Renaming computer to above serial number value    aka Dell Service Tag
Rename-Computer -NewName "$CN" -Restart

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ