После установки Windows Server или дестопной Windows 10/11, вам нужно изменить имя компьютера, заданное по-умолчанию. Чаще всего в имени компьютер рекомендуется указывать его местоположение или роль, например:
msk-dc01
,
wks-mskIT12
,
MRKTG021
и т.д. Можно использовать серийный или инвентарный номер устройства в качестве имени компьютера.
Содержание:
- Переименовать компьютер из графического интерфейса Windows
- Изменить имя компьютера с помощью PowerShell
При установке Windows сама генерирует имя компьютера формата, например,
DESKTOP-P2FHTKQ
. Имя содержит 15 символов, первые семь берутся из имени организации, остальные символы генерируются случайным образом. Для домашнего компьютера имя обычно не имеет особого значение, но если ваш компьютер находится в организации и работает в составе рабочей группы или домена AD, желательно задать осмысленное имя компьютера. В этой статье мы покажем, как переименовать компьютер Windows.
Имя компьютера должно соответствовать следующим требованиям:
- Длина не более 15 символов
- Не должно содержать специальных символов (< > ; : » * + = \ | ? ,)
- Можно использовать тире и нижнее подчеркивание
- Не должно состоять только из цифр
- Имя компьютера регистр независимо
- Если компьютер будет добавлен в домен Active Directory, имя компьютера должно быть уникальным в пределах домена.
Переименовать компьютер из графического интерфейса Windows
В современных версиях Windows 10 и 11 вы можете переименовать компьютер с помощью панели Settings.
- Нажмите
Win+I
и перейдите в раздел System -> About (можно использовать URI команду
ms-settings:about
для быстрого доступа к разделу Settings); - Нажмите на кнопку Rename this PC;
- Укажите новое имя компьютера и нажмите Next;
- Перезагрузите компьютер, чтобы применить изменения.
Также вы можете изменить имя компьютера из классического интерфейса System Properties в Windows:
- Нажмите
Win+R
на клавиатуре и выполните команду
sysdm.cpl
или
systempropertiescomputername
; - Здесь отображается текущее имя компьютер и имя вашего домена или рабочей группы;
- Нажмите на кнопку Change, укажите новое имя компьютера и сохраните изменения.
- Перезагруите Windows
В Windows Server вы можете изменить имя компьютера через Server Manager. Выберите раздел Local Server и нажмите по имени в поле Computer Name.
Изменить имя компьютера с помощью PowerShell
Вы можете переименовать компьютер из командной строки с помощью PowerShell командлета Rename-Computer.
Откройте консоль PowerShell с правами администратора. Чтобы узнать текущее имя компьютера, выполните команду:
$env:computername
Или:
Hostname
Если вам нужно получить FQDN компьютера:
$env:computername.$env:userdnsdomain
Чтобы изменить имя компьютера, выполните:
Rename-Computer -NewName "WKS-MSKO12S3"
Теперь можно перезагрузить компьютер с помощью команды Restart-Computer (или можно добавить опцию перезагрузки прямо в команду смены имени хоста):
Rename-Computer -NewName "WKS-MSKO12S3" –Restart -Force
После перезагрузки проверьте, что имя компьютера сменилось успешно.
Если этот компьютер был добавлен в домен AD перед сменой имени и находился в определенной OU (Organization Unit), его учетная запись но уже с новым именем по прежнему будет находится в том же самом контейнере. Можете проверить это с помощью консоли ADUC. Для переименования компьютера в AD вашей учетной записи должны быть делегированы разрешения на создание и удаление объектов Computers в этой OU.
Командлет Rename-Computer позволяет сменить имя удаленного компьютера. Используйте команды:
Rename-Computer -ComputerName "msk-test" -NewName "msk-preprod02" -DomainCredential Contoso\Admin01 –Force
Для подключения к удаленному компьютеру используется WMI, поэтому если он отключен на удаленном хосте или сетевые порты заблокированы, появится ошибка:
Rename-Computer : Cannot establish the WMI connection to the computer ‘priorauthdes’ with the following error message: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
Можно использовать командлеты PowerShell Remoting для подключения к удаленному компьютеру. Если вы включили на удаленном компьютере WinRM вручную или настроили его с помощью GPO, можно использовать командлет Invoke-Command для запуска команды на удаленном компьютере. Чтобы переименовать удаленный компьютер, выполните:
Invoke-Command -ComputerName msk-test -ScriptBlock { Rename-Computer -NewName msk-preprod02 –Restart -Force}
Также для переименования компьютера ранее использовалась утилита netdom:
- Переименовать локальный компьютер:
netdom renamecomputer localhost /newname msk-preprod02 /reboot - Сменить имя удаленного компьютера:
netdom renamecomputer msk-test /newname:msk-preprod02 /userd:CONTOSO\Admin01 /password:*
В Windows Serve Core можно использовать встроенную псевдографическую команду sconfig для переименования компьютера.
Если вы устанавливаете ваш эталонный образ Windows на компьютеры с помощью автоматизированных средств установки (WDS, SCCM или по сети с помощью PXE), вы можете добавить в них небольшой скрипт для автоматического переименования компьютера в соответствии с политиками именования вашей организации.
Обновлено:
Опубликовано:
В статье представлены распространенные способы смены имени компьютера:
Через графический интерфейс
В Windows 10
Через командную строку
С помощью Powershell
Через реестр
Читайте также
Данные рекомендации подойдут для разных версий операционной системы Windows от XP до 10.
Универсальный через графический интерфейс
Открываем свойства компьютера. Для этого открываем проводник и кликаем правой кнопкой мыши по Компьютер и выбираем Свойства:
… или вводим команду:
control /name microsoft.system
В открывшемся окне в разделе «Имя компьютера, имя домена и параметры рабочей группы» нажимаем Изменить параметры:
В следующем окне на вкладке Имя компьютера нажимаем Изменить:
Вводим имя компьютера:
* если кликнуть по кнопке Дополнительно, мы сможем добавить DNS-суффикс и поменять NetBIOS-имя компьютера.
Нажимаем OK два раза и перезагружаем компьютер.
Графический интерфейс Windows 10
В Windows 10 появился дополнительный вид панели управления. Ее также можно использовать для смены имени компьютера.
Кликаем по Пуск и нажимаем на изображение шестеренки:
Кликаем по Система:
В разделе О системе:
… кликаем по Переименовать этот ПК:
Вводим новое имя и нажимаем Далее:
Перезагружаем компьютер.
Через командную строку
Запускаем командную строку от имени администратора и вводим следующую команду:
> netdom renamecomputer %COMPUTERNAME% /Newname «computername»
* computername — новое имя компьютера
После ввода система запросит подтверждение — отвечаем Y и нажимаем Enter.
Для вступления изменений в силу, перезагружаем компьютер.
С помощью Powershell
Что такое Powershell простыми словами.
Запускаем Powershell от имени администратора и вводим следующую команду:
> netdom renamecomputer «$env:COMPUTERNAME» /Newname «computername»
Как и с командной строкой, система запросит подтверждение операции, на которое отвечаем Y.
После перезагружаем компьютер для завершения операции.
Через реестр
Для изменения компьютера в реестре нам нужно отредактироват два параметра:
- Ветка HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName, параметр ComputerName, значение — имя компьютера.
- Ветка HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, параметр NV HostName, значение — имя компьютера.
Для внесения изменений можно воспользоваться утилитой regedit или командами:
reg add «HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName» /v ComputerName /t REG_SZ /d «Office-3» /f
reg add «HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters» /v ComputerName /t REG_SZ /d «Office-3» /f
* в данном примере мы задаем имя компьютеру Office-3.
После перезагружаемся.
Читайте также
Создание нового пользователя в Windows 10
Три способа добавить компьютер с Windows к домену
There is a plethora of reasons a computer or server might need to be renamed. It could be due to a reorg, a merger, or simply to clean up asset tracking. Regardless, changing the name of a computer or server is really simple, especially with PowerShell.
Renaming a computer can be done using the Rename-Computer command in PowerShell. This cmdlet can be used to rename both local and remote computers and can be automated with use of scripting for bulk changes.
The Rename-Computer cmdlet has a NewName parameter which specifies the new name for the target computer.
Here is the syntax for the Rename-Computer cmdlet:
Rename-Computer [-NewName] <System.String> [-ComputerName <System.String>] [-DomainCredential
<System.Management.Automation.PSCredential>] [-Force] [-LocalCredential
<System.Management.Automation.PSCredential>] [-PassThru] [-Protocol {DCOM | WSMan}] [-Restart]
[-WsmanAuthentication {Default | Basic | Negotiate | CredSSP | Digest | Kerberos}] [-Confirm] [-WhatIf]
[<CommonParameters>]
You can pull up this syntax list yourself by opening PowerShell and entering “Get-Help Rename-Computer”
Here is a description of the parameters:
- -NewName: Specifies the new name for the computer. It is required to rename a computer. The name can contain alphanumeric characters and hyphens (-).
- -ComputerName: Specifies the remote computer to be renamed. The default value is the local computer. To specify a remote computer, use the IP address, domain name, or NetBIOS name of the computer. To specify the local computer, type the computer name, a dot (.), or “localhost”
- -DomainCredential: Specifies a user account that has permission to connect to a remote computer in the domain and rename it. Use the format Domain\User or use the Get-Credential cmdlet to get the user credentials.
- -Force: This parameter forces the command to execute without user confirmation.
- –LocalCredential: Same effect as DomainCredential but uses an account on the local machine rather than the domain.
- –PassThru: Returns the results of the command within the PS prompt window.
- -Restart: Specifies that the computer should be restarted after it is renamed in order to apply the new name system wide in Windows.
- –WhatIf: Shows (simulates) what changes will be made should you run the command string.
Now, let’s look at some examples that use the Rename-Computer cmdlet. These steps are applicable to any Windows 10, Windows 11, or Windows Server machine.
Related: How to Install PowerShell Modules in Windows 10 & Windows Server
To rename a local computer, use the following command:
Rename-Computer -NewName "NPGPC1" -Restart
This will rename the local computer to NPGPC1 and restart it to reflect the changes.
Rename a Remote Computer
To rename a remote computer, use the following command:
Rename-Computer -ComputerName "NPGPC1" -NewName "NPGPC2" -Restart
This will rename the remote computer NPGPC1 to NPGPC2 and restart it to commit the changes.
In some situations, you may need to enable PS Remoting on the remote computer before it will accept PowerShell connections. You do this with:
Enable-PSRemoting -Force
Rename a Computer on a Domain
To rename a computer on a domain, you must have permission to connect to the domain. You can use explicit credentials with the DomainCredential parameter and the Get-Credential cmdlet.
An example of renaming a computer on a domain would be:
Rename-Computer -ComputerName "NPGPC1" -NewName "NPGPC2" -DomainCredential NPGDOM\DomAdmin -Force
This will rename the remote computer NPGPC1 to NPGPC2 on the domain, using the user account NPGDOM\DomAdmin for explicit credentials. The Force parameter will execute the command without a prompt for user confirmation.
Rename a Workgroup Computer
For computers that are members of a workgroup you can use the -LocalCredential parameter. For example, open a PowerShell console as administrator and enter:
Rename-Computer -ComputerName "NPGPC1" -NewName "NPGPC2" -LocalCredential NPGPC1\Admin -Force
Renaming Multiple Computers with a CSV File
You can import a csv file into PowerShell to programmatically rename a list of computers. To do this, set up a csv file with a row containing the original name and new name you wish to use for each computer. For example:
We can then use the following script to import the file and loop through the list using the commands shared earlier:
$File = 'c:\rename-computers-list.csv' //path to your csv file
$Credential=Get-Credential
$computerList= Import-Csv -Path $File -Delimiter "," -Header OldName,NewName
foreach ($Computer in $computerList)
{
Rename-Computer -ComputerName $Computer.OldName -NewName $Computer.NewName -DomainCredential $Credential -Force -Restart
}
Considerations and Repercussions When Renaming a Computer or Server
Before you go willy-nilly renaming computers in your environment, be mindful of the following:
- The name needs to comply with your organization’s naming conventions.
- The new name needs to be unique, so it doesn’t interfere with domain and application connectivity with another computer on the domain.
- Make sure there are no existing DNS or DHCP entries for the name you are about to use that may cause an IP conflict once renamed.
- Verify the user account you are using has permission to rename computers on the domain.
- Be mindful of any services or applications that depend on the computer’s name and be sure they are updated with the new name post change.
- Make sure any mapped drives or connections to the computer are updated with the new name.
- Make sure any services or applications that depend on the computer’s name are updated with the new name. This may include services that use a service principal name (SPN) or Kerberos delegation.
- If you’re renaming a remote computer, make sure your method of remote connectivity will continue to work or allow you to reconnect to the computer once it is renamed.
- If the computer has any group policy objects (GPOs) applied to it verify they are updated with the new computer name otherwise they may quit functioning properly. Double check group policy health with gpresults after renaming.
- The computer’s security identifier (SID) will be changed, which may cause issues with access to resources, application, and anything else that is coded to rely on the SID.
- If you’re using any remote monitoring and management (RMM) utilities or the like, make sure they are updated with the new name, so you don’t lose track of the computer.
- If the computer or server is physical and has an asset tag, you’ll need to update this so your asset tracking doesn’t get jacked.
Recommended Tool: ManageEngine OpManager
- Multi-vendor Network Monitoring
- Simple Installation & Setup
- Intuitive UI
- Complete Visibility
- Intelligent Detections
- Easy Resolutions
Network Engineer III
I am a Senior Network Engineer who has spent the last decade elbow deep in enterprise System Administration and Networking in the local government and energy sectors. I can usually be found trying to warm up behind the storage arrays in the datacenter.
In this PowerShell tutorial, we will learn how to change the computer name in Windows using the Rename-Computer Cmdlet. It is a very simple and easy-to-use PowerShell command.
The Rename-Computer Cmdlet has the following syntax, where NewComputerName is the name you want to use:
Rename-Computer -NewName NewComputerName
Rename-Computer -NewName NewComputerName -Restart
Rename-Computer -ComputerName <IP/Name> -NewName NewComputerName
The rename operation required a restart. If you use the -Restart option, it will automatically restart the computer.
Examples
In our first example, we change the computer name to Desktop-1 (the changes will only take effect after you restart the computer):
Rename-Computer -NewName Desktop-01
In the following example, we add the -Restart parameter to the Rename-Computer cmdlet. It will automatically restart the computer without giving a warning message:
Rename-Computer -NewName Desktop-01 -Restart
You can check the computer name by running the hostname command:
hostname
Changing the Name of a Remote Computer
If you want to rename a remote computer, you need to specify the name or IP address of the remote computer using the -ComputerName parameter.
In this example, we rename Desktop-01 to Desktop-02. We use the -DomainCredential parameter to specify a user account that has permission to connect to the domain. In this example, example.com is the domain name:
Rename-Computer -ComputerName "Desktop-01" -NewName "Desktop-02" -DomainCredential example.com\administrator
In the following example, we change the name of the computer with an IP Address 192.168.100.10:
Rename-Computer -ComputerName 192.168.100.10 -NewName "Desktop-02" -DomainCredential example.com\administrator -Force -Restart
If the remote computer is not in the domain, use the -LocalCredential parameter to specify a local user account that has permission to rename the computer, as shown in the following example:
Rename-Computer -ComputerName 192.168.100.10 -NewName Desktop1 -LocalCredential 192.168.100.10\user1
When renaming a remote computer, you may get the following common errors:
The RPC server is unavailable.Rename-Computer : Cannot establish the WMI connection to the computer '192.168.100.10' with the following error message: Access is denied.
We can solve the first error by enabling the Windows Management Instrumentation from the Windows Firewall on the remote computer. To fix the second error, you need to disable UAC remote restrictions on the target computer.
Click the following link for detailed instructions on how to fix those two errors: www.configserverfirewall.com/powershell/cannot-establish-the-wmi-connection-to-the-computer/.
Command Options
The following table describes the parameters of the Rename-Computer Cmdlet.
| -NewName | Use this option to specify the new name for the computer. This is the only required parameter. |
| -Restart | Use the -Restart switch to restart the computer. |
| -ComputerName | Use this option to specify the IP Address or name of the remote computer. |
| -DomainCredential | Specifies a domain user account that has permission to rename the computer. |
| -LocalCredential | When renaming a computer that is not on a domain, use this option to specify a local user account that has permission to connect to the remote computer. |
| -Force | Run the command without asking for user confirmation. |
| -Confirm | Asks for the confirmation before renaming the computer. |
| -PassThru | Returns the results of the command (shows whether the command was successful or not). |
To rename a computer using PowerShell, you can use the `Rename-Computer` cmdlet followed by specifying the new name and, if necessary, the credentials. Here’s how you can do it:
Rename-Computer -NewName "NewComputerName" -Restart
Make sure to replace `»NewComputerName»` with your desired computer name.
Understanding Computer Naming Conventions
When renaming a computer, it’s essential to follow certain naming conventions to ensure compatibility within a network. Computer names have specific requirements, such as:
- Length Limits: Most systems mandate that the computer name can be up to 15 characters long.
- Character Restrictions: Names can contain letters (A-Z, a-z), numbers (0-9), and some special characters (_ and -) but cannot include spaces.
Each computer within a network must have a unique name to avoid conflicts. It is also crucial to differentiate between local names (used within a single network) and network names (used to identify computers on a broader scope).
PowerShell: Rename Computer and Join Domain Made Easy
PowerShell Basics for Beginners
For those new to PowerShell, understanding the fundamental components will enhance your ability to execute commands efficiently. PowerShell utilizes cmdlets, which are specialized .NET classes that perform actions. Each cmdlet follows a standard structure: `Verb-Noun`, such as `Get-Process`.
Familiarizing yourself with parameters and objects is vital. Parameters allow you to modify the behavior of cmdlets while objects represent the data that cmdlets manipulate.
PowerShell Restart Computer: A Simple Guide
Why Use PowerShell to Rename a Computer?
PowerShell provides several advantages when renaming a computer compared to traditional graphical user interface (GUI) methods:
- Speed and Efficiency: Renaming a computer via PowerShell can be executed quickly through a simple command, whereas GUI methods require multiple steps.
- Automation Capabilities: Using PowerShell enables you to write scripts that can rename multiple computers, enhancing productivity especially in larger environments.
There are various scenarios where renaming may be necessary, such as organizational restructuring or standardization of machine names across your network.
PowerShell Rename Folder: A Quick How-To Guide
The Rename-Computer Cmdlet
What is Rename-Computer?
The `Rename-Computer` cmdlet is a powerful tool in PowerShell used specifically for changing the name of the local or a remote computer. This cmdlet is integral for system administrators who need to manage machine identities without interrupting workflows.
Syntax of Rename-Computer
The general syntax of the `Rename-Computer` cmdlet is straightforward, allowing you to specify the new name and optionally restart the computer:
Rename-Computer -NewName "NewComputerName" -Restart
PowerShell Restart-Computer -Force: A Quick Guide
Steps to Rename Your Computer Using PowerShell
Opening PowerShell
To begin, you’ll need to open PowerShell in administrator mode to ensure you have the required permissions. You can do this by searching for «PowerShell» in the Windows search bar, right-clicking on it, and selecting «Run as administrator.»
Before executing any commands, be aware of execution policies, which may prevent scripts from running. You might need to change the execution policy with the command:
Set-ExecutionPolicy RemoteSigned
Using Rename-Computer to Change the Name
Basic Rename Command
To rename your computer, you can use the following command:
Rename-Computer -NewName "NewPCName"
This command will change the computer’s name to «NewPCName.» To apply the new name, you will need to restart the system.
Renaming with Network Considerations
If you’re renaming a computer that is part of a domain, you’ll want to specify the domain credentials. Here’s how to do this:
Rename-Computer -NewName "DomainNewPCName" -DomainCredential Domain\User -Restart
This command not only changes the name but also ensures that the new name aligns with your network policies.
Validating the New Computer Name
After executing the rename command, you may want to verify that the name has changed successfully. You can do so using:
Get-ComputerInfo | Select-Object CsName
This command retrieves the current hostname, allowing you to confirm the change.
Mastering PowerShell Get ADComputer for Effortless Queries
Handling Common Issues
Permission Denied Errors
Sometimes, you might encounter permission denied errors while attempting to rename your computer. This usually occurs if PowerShell lacks the necessary administrative rights. Ensure you are running PowerShell as an administrator.
Renaming Failures
If the rename command fails, it could be due to several factors, such as:
- Invalid name: Ensure the new name adheres to the naming conventions discussed earlier.
- Existing name: Check if a computer with the desired name already exists in the network.
To troubleshoot, consider reviewing the error messages provided by PowerShell and adjusting your command accordingly.
PowerShell Delete Computer From AD: A Step-By-Step Guide
Automating Computer Renames with Scripts
How to Create a PowerShell Script for Renaming
For environments with multiple computers, you can automate the renaming process with a PowerShell script. Here’s an example of a simple loop that changes the names of multiple machines:
$NewNames = ("PC1", "PC2", "PC3")
foreach ($Name in $NewNames) {
Rename-Computer -NewName $Name -Restart
}
This script will sequentially rename the computer to «PC1,» «PC2,» and «PC3,» restarting after each rename. This automation can drastically reduce the time spent managing multiple machines.
PowerShell Disable Computer Account: A Quick Guide
Additional Considerations
Restarting the Computer
After executing the `Rename-Computer` command, a restart is generally necessary for the changes to take effect fully. You can automate restarts by adding the `-Restart` parameter, as seen in previous examples.
Other Related Cmdlets
Beyond `Rename-Computer`, there are other cmdlets worth knowing. For example:
- Set-ComputerName: Can also be used for renaming tasks.
- Get-ComputerInfo: Provides detailed information about the computer, including the current name.
PowerShell Get Computer Info: A Quick Guide
Conclusion
Being adept at using PowerShell to rename computers is an invaluable skill for system administrators and tech enthusiasts alike. Mastering the `Rename-Computer` cmdlet will save you time and allow for more efficient management of computer names in various environments.
Mastering the PowerShell Enumerator: A Quick Guide
Resources for Further Learning
To further enhance your PowerShell skills, consider exploring various online resources, tutorials, and books. Engaging with PowerShell communities and forums can also provide additional support and insights into advanced PowerShell usage.
As you dive into your journey of using PowerShell for administrative tasks, don’t hesitate to experiment with different commands and scripts to uncover the tool’s full capabilities.
