Last active
October 30, 2025 01:18
-
-
Save asheroto/4e4f3e2308d9dc3293d9a4e155bd70d2 to your computer and use it in GitHub Desktop.
Rename a Dell computer to the computer's service tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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