Change Username and full name.
- 03 Nov 2023
- 1 Minute to read
- Print
- PDF
Change Username and full name.
- Updated on 03 Nov 2023
- 1 Minute to read
- Print
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
The following PowerShell script helps the IT Admins change the username and full name of the users on the managed Windows devices.
- Create a file on your desktop, for example, To_change_username_and_fullname.ps1 and open it in a text editor like notepad++
- Copy the contents below to the file or click here to download the file.Shell
# Define the old and new usernames and full names $oldUsername = "old_username" $newUsername = "new_username" $newFullName = "new_fullname" # Check if the old username exists if (Get-WmiObject Win32_UserAccount | Where-Object { $_.Name -eq $oldUsername }) { # Rename the user account (username) Rename-LocalUser -Name $oldUsername -NewName $newUsername # Modify the user's full name Get-WmiObject Win32_UserAccount -Filter "Name='$newUsername'" | ForEach-Object { $_.FullName = $newFullName $_.Put() } Write-Host "User account $oldUsername has been renamed to $newUsername, and the full name has been updated to $newFullName." } else { Write-Host "User account $oldUsername not found." }
- Replace the data in the script as shown below with the correct new usernames and new full name, for example: Shell
$oldUsername = "Jinny" $newUsername = "Liza" $newFullName = "Liza"
- Replace the data in the script as shown below with the correct new usernames and new full name, for example:
- Follow our guide to upload & publish the PowerShell script using Scalefusion Dashboard.
- Once the script is successfully executed, you will be able to see the status of the same in the View Status report on the Scalefusion dashboard.
Notes:
- The scripts and their contents are sourced from various albeit authenticated Microsoft sources and forums.
- Please validate the scripts on a test machine before deploying them on all your managed devices.
- Scalefusion has tested these scripts, however, Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the incorrect usage of these scripts.
Was this article helpful?