top of page

Using Custom PowerShell script to rename your PC

  • Steven Paniccia
  • Oct 2, 2024
  • 2 min read

Are you looking to personalize your Dell PC or simply want to give it a more fitting name? Renaming your computer can enhance your organization and make it easier to identify on a network. While there are various ways to do this through the Windows interface, using PowerShell is a powerful and efficient method that can save you time and effort. In this blog post, we’ll walk you through the simple steps to rename your Dell PC using a PowerShell command, ensuring your computer reflects your unique style or purpose. Whether you’re a seasoned techie or a curious beginner, this guide will help you master the process with ease. Let’s dive in!



The Script


Open notepad and copy and paste the following code:


# Get the service tag using WMI

$serviceTag = (Get-WmiObject -Class Win32_BIOS).SerialNumber


# Define the new computer name

$newComputerName = "Dell-PC-" + $serviceTag


# Output the new computer name

Write-Host "New Computer Name: $newComputerName"


# Rename the computer

Rename-Computer -NewName $newComputerName -Force -Restart


Select Save as and name the file. In this example we'll name this file to pc rename.ps1 Make sure you change the Save as type to all files. then select save.



Breaking down the script


The first section of script:


      # Get the service tag using WMI

      $serviceTag = (Get-WmiObject -Class Win32_BIOS).SerialNumber


Get-WmiObject -Class Win32_BIOS: This command grabs BIOS information from the computer.


.SerialNumber: This extracts the BIOS serial number, which is usually the Dell service tag.


$serviceTag: This variable saves the service tag for later use.


The second section of the script:

      # Define the new computer name

      $newComputerName = "Dell-" + $serviceTag


$newComputerName: This variable will hold the new name for the computer.


"Dell-" + $serviceTag: This combines the text "Dell-" with the service tag, creating the new computer name.


The third section of the script:

      # Output the new computer name

      Write-Host "New Computer Name: $newComputerName"


Write-Host: This command displays messages in the console.


"New Computer Name: $newComputerName": This shows the new computer name to the user, letting them know what it will be changed to.


and the final section of the script:

      # Rename the computer

      Rename-Computer -NewName $newComputerName -Force -Restart


Rename-Computer: This command renames the computer.


-NewName $newComputerName: This specifies the new name, which is stored in the $newComputerName variable.


-Force: This allows the renaming to happen without asking for confirmation.


-Restart: This option automatically restarts the computer to apply the new name.



Renaming your Dell PC is a straightforward yet impactful way to personalize your computing experience and streamline your digital organization. By following the steps outlined in this guide, you can effortlessly use PowerShell to give your computer a name that resonates with your unique identity or functional needs. Whether you want to make your device more recognizable on a network or simply express your personal style, a customized name can enhance your overall experience. So go ahead and take control of your tech environment—embrace the power of personalization and let your Dell PC truly reflect who you are! Happy renaming!

Comments


bottom of page