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
Answers (1)
Please log in to answer
Posted by:
mark.adams
7 years ago
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 - flip1001 7 years ago