This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.

Rename-Computer

Synopsis

Rename the local or a remote computer.

Syntax

  • Rename-Computer [-ComputerName] [-NewName] [-Reboot] [-Credential]

Description

Rename-Computer replaces the original Rename-Computer cmdlet found in pre-release Powershell 2 and is also usable against remote computers. Rename-Computer requires a reboot for the changes it makes to take effect and the -Reboot parameter of this cmdlet is included for this purpose.

It should be noted that Rename-Computer does not make checks as to the suitability of renaming the target computer and care should be taken when renaming computers running services that rely on a fixed computer name, such as Certificate Authorities.

Parameters

  • ComputerName The computer against which to run the cmdlet. By default this parameter will be populated with the name of the local computer.
  • NewName The name to which the target computer should be renamed. Names longer than 15 characters will be rejected.
  • Reboot Reboot the computer so that configuration changes take effect.
  • Credential The credentials under which to run the cmdlet. By default this cmdlet will run as the current user. Using this parameter and the Get-PSCredential cmdlet you can specify an alternate set of credentials under which to execute this command.

Inputs

Rename-Computer accepts pipeline input only for the ComputerName parameter and requires that the input object contain a property named either Computer, CN or ComputerName.

Outputs

Rename-Computer does not output any Powershell objects.

Notes

The cmdlet requires that the Remote Registry and RPC services are started on the computer it is trying to access and that DNS services are available to resolve target host names.

Example 1

This command will rename the local computer to PC04 and reboot so that the changes take effect:

Rename-Computer -NewName PC04 -Reboot

Example 2

This command will rename the remote computer PC01 to PC02.:

Rename-Computer -Computer PC01 -NewName PC02

Example 3

This command will rename the local computer to PC02 and reboot so that the changes take effect:

Rename-Computer -Computer PC01 -NewName PC02 -Reboot -Confirm:$false