Skip to content

Instantly share code, notes, and snippets.

@asheroto
Last active October 30, 2025 01:18
Show Gist options
  • Select an option

  • Save asheroto/4e4f3e2308d9dc3293d9a4e155bd70d2 to your computer and use it in GitHub Desktop.

Select an option

Save asheroto/4e4f3e2308d9dc3293d9a4e155bd70d2 to your computer and use it in GitHub Desktop.
Rename a Dell computer to the computer's service tag
#Requires -RunAsAdministrator
# Get Dell Service Tag
# If empty or serial number is greater than 7 characters, exit script
$serial = (get-wmiobject win32_systemenclosure | select serialnumber).serialnumber
if ($serial.length -eq 0 -or $serial.length -gt 7) { Write-Output "Service tag not detected! Failed rename."; exit; }
Write-Output "Dell Service Tag: $serial"
Write-Output ""
# Rename
Write-Output "Renaming computer to $serial"
Write-Output ""
Rename-Computer -NewName $serial
Write-Output ""
Write-Output "Done! Restart computer to complete the rename. This script will not restart the computer automatically."
Write-Output ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment