Script to Change PC name with prefix + Serialnumber

Hello. I am hoping to get a script created to rename PC’s with a prefix and the PC serial number. I have a powershell script that should work but open to anything else.

$SerialNumber = (Get-WmiObject -class win32_bios).SerialNumber
$computer = “PrefixHere-$SerialNumber”
Rename-Computer -NewName $computer -Force

With changing PrefixHere to what prefix I am looking for example would be USAV-Serialnumber. I see there is a script to run a powershell script but involves the .ps1 file to be copied to the pc first which is not an option in my case.

hi @PremJKumar

please do look into this request.

thank you

Hi @vartabedian ,

Thanks for your script request. we have created an internal script task “CS-61493” and assigned it to our script developer.

Kind Regards,
PremJK

Hi @vartabedian ,

Our script developer has provided script as requested
https://scripts.xcitium.com/frontend/web/topic/script-to-change-pc-name-with-prefix-and-serial-number

Note: Run the script as Local System User

You can change the variable “prefix”
prefix = “COMP” # You can change this to any desired prefix

it will automatically restart the computer within 60 seconds(which can be changed).

Kind Regards,
PremJK