PowerShell Logo Small

Rename-Computer



This is the built-in help made by Microsoft for the command 'Rename-Computer', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Renames a computer.

SYNTAX


Rename-Computer [-NewName] <String> [-ComputerName <String>] [-DomainCredential <PSCredential>] [-Force] [-LocalCredential <PSCredential>]
[-PassThru] [-Restart] [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Rename-Computer cmdlet renames the local computer or a remote computer. It renames one computer in each command.


This cmdlet is introduced in Windows PowerShell 3.0.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkID=135253
Add-Computer
Remove-Computer
Reset-ComputerMachinePassword
Restart-Computer
Stop-Computer

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>Rename-Computer -NewName Server044 -DomainCredential Domain01\Admin01 -Restart



This command renames the local computer to Server044 and then restarts it to make the change effective.




-------------------------- EXAMPLE 2 --------------------------

PS C:\>Rename-Computer -ComputerName Srv01 -NewName Server001 -LocalCredential Srv01\Admin01 -DomainCredential Domain01\Admin01 -Force
-PassThru -Restart



This command renames the Srv01 computer to Server001 and then restarts it to make the change effective. It uses the LocalCredential parameter
to supply the credentials of a user who has permission to connect to the local computer and the DomainCredential parameter to supply the
credentials of a user who has permission to rename computers in the domain. It uses the Force parameter to suppress the confirmation prompt
and the PassThru parameter to return the results of the command.




-------------------------- EXAMPLE 3 --------------------------

PS C:\>$a = Import-Csv ServerNames.csv -Header OldName, NewName

PS C:\>Foreach ( $Server in $a ) { Rename-Computer -ComputerName $Server.OldName -NewName $Server.NewName -DomainCredential Domain01\Admin01
-Force -Restart }



This command renames multiple computers in the domain. It uses a CSV file to specify the values for the current and new names of each
computer. The CSV file contains a series of name pairs in "OldName, NewName" format with one name pair on each line of the file.

The first command uses the Import-Csv cmdlet to import the ServerNames.csv file into the $a variable. It uses the Header parameter to specify
the column header names of each of the two columns. This creates a collection of custom objects in $a, each of which has an OldName and
NewName property.

The second command runs the Rename-Computer cmdlet on each object in the $a variable. It specifies the old name (the value of the OldName
property) for the value of the ComputerName parameter and the new name (the value of the NewName property) for the value of the NewName
parameter. The command specifies domain credentials and uses the Force and Restart parameters to suppress all user prompts and restart each
computer after it is renamed.