MoonPoint Support Logo

 




Advanced Search
July
Sun Mon Tue Wed Thu Fri Sat
     
17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
2026
Months
JulAug Sep
Oct Nov Dec


Fri, Jul 17, 2026 9:30 pm

Renaming a Windows system and joining a Windows domain with PowerShell

You can view the current name of a system running a Microsoft Windows operating system (OS) using the hostname command in a PowerShell or command prompt window. You can change the name of the host by opening a PowerShell window with administrator privileges by choosing "Run as administrator" when opening the window and then using the PowerShell command Rename-Computer -NewName "name" where name is the new name you wish to assign to the system. Note: names must be 15 or fewer characters due to NetBIOS limitations and should only use standard alphanumeric characters, i.e, A-Z, 0-9, and hyphens (-). Spaces and most special characters are invalid and will cause an error.

PS C:\Windows\system32> hostname
DESKTOP-PNS32H3
PS C:\Windows\system32> Rename-Computer -NewName "Jamestown"
WARNING: The changes will take effect after you restart the computer DESKTOP-PNS32H3.
PS C:\Windows\system32>

You will need to reboot to have the new name go into effect; you can add the -Restart option to the command to restart automatically. E.g., Rename-Computer -NewName "TheNewName" -Restart.

To join a Windows domain from a command-line interface (CLI), you can issue the command Add-Computer -DomainName "YourDomainName" -Credential (Get-Credential) -Restart — replace YourDomainName with the name of the Windows domain. If you don't want to automatically reboot, omit the -Restart option.

Add-Computer -DomainName "ad.example.com" -Credential (Get-Credential) -Restart

cmdlet Get-Credential at command pipeline postion 1
Supply values for the following parameters:
Credential

You will see a "Windows PowerShell credential request" window open where you can provide a user name and password for an account in the domain administrators group. The system will automatically reboot if you have added the -Restart parameter.

[/os/windows/PowerShell] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo