< Back
Rename-Computer
Post
NAME Rename-Computer
SYNOPSIS
Renames a computer.
SYNTAX
Rename-Computer [-NewName] <String> [-ComputerName <String>] [-Confirm] [-DomainCredential <PSCredential>] [-Force] [-LocalCredential
<PSCredential>] [-PassThru] [-Protocol {DCOM | WSMan}] [-Restart] [-WhatIf] [-WsmanAuthentication {Default | Basic | Negotiate | CredSSP | Digest
| Kerberos}] [<CommonParameters>]
DESCRIPTION
The Rename-Computer cmdlet renames the local computer or a remote computer. It renames one computer in each command.
This cmdlet was introduced in Windows PowerShell 3.0.
PARAMETERS
-ComputerName <String>
Renames the specified remote computer. The default is the local computer.
Type the NetBIOS name, an IP address, or a fully qualified domain name of a remote computer. To specify the local computer, type the computer
name, a dot (.), or localhost.
This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of Rename-Computer even if your computer
is not configured to run remote commands.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-DomainCredential <PSCredential>
Specifies a user account that has permission to connect to the domain. Explicit credentials are required to rename a computer that is joined
to a domain.
Type a user name, such as User01 or Domain01\\User01, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If
you type a user name, this cmdlet prompts you for a password.
To specify a user account that has permission to connect to the computer that is specified by the ComputerName parameter, use the
LocalCredential parameter.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Force [<SwitchParameter>]
Forces the command to run without asking for user confirmation.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-LocalCredential <PSCredential>
Specifies a user account that has permission to connect to the computer specified by the ComputerName parameter. The default is the current
user.
Type a user name, such as User01 or Domain01\\User01, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If
you type a user name, this cmdlet prompts you for a password.
To specify a user account that has permission to connect to the domain, use the DomainCredential parameter.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-NewName <String>
Specifies a new name for the computer. This parameter is required. The name cannot include control characters, leading or trailing spaces, or
any of the following characters: / \\\\ [ ].
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Returns the results of the command. Otherwise, this cmdlet does not generate any output.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Protocol <String>
Specifies which protocol to use to rename the computer. The acceptable values for this parameter are: WSMan and DCOM. The default value is
DCOM.
This parameter was introduced in Windows PowerShell 3.0.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Restart [<SwitchParameter>]
Indicates that this cmdlet restarts the computer that was renamed. A restart is often required to make the change effective.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WsmanAuthentication <String>
Specifies the mechanism that is used to authenticate the user credentials when this cmdlet uses the WSMan protocol. The acceptable values for
this parameter are:
- Basic
- CredSSP
- Default
- Digest
- Kerberos
- Negotiate
The default value is Default.
For more information about the values of this parameter, see AuthenticationMechanism Enumerationhttp://go.microsoft.com/fwlink/?LinkID=235230
(http://go.microsoft.com/fwlink/?LinkID=235230) in the Microsoft Developer Network (MSDN) library.
Caution: Credential Security Service Provider (CredSSP) authentication, in which the user credentials are passed to a remote computer to be
authenticated, is designed for commands that require authentication on more than one resource, such as accessing a remote network share. This
mechanism increases the security risk of the remote operation. If the remote computer is compromised, the credentials that are passed to it
can be used to control the network session.
This parameter was introduced in Windows PowerShell 3.0.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
This cmdlet does not have parameters that take input by value. However, you can pipe the values of the ComputerName and NewName properties of
objects to this cmdlet.
OUTPUTS
Microsoft.PowerShell.Commands.ComputerChangeInfo
This cmdlet returns a ComputerChangeInfo object, if you specify the PassThru parameter. Otherwise, it does not return any output.
NOTES
Example 1: Rename the local computer
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: Rename a remote computer
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: Rename multiple computers
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, which is the value of the OldName
property, for the value of the ComputerName parameter. It specifiesthe new name, the value of the NewName property, for the value of the NewName
parameter. The command specifies domain credentials and uses Force and Restart to suppress all user prompts and restart each computer after it is
renamed.
RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=821620
Add-Computer
Remove-Computer
Reset-ComputerMachinePassword
Restart-Computer
Stop-Computer
SYNOPSIS
Renames a computer.
SYNTAX
Rename-Computer [-NewName] <String> [-ComputerName <String>] [-Confirm] [-DomainCredential <PSCredential>] [-Force] [-LocalCredential
<PSCredential>] [-PassThru] [-Protocol {DCOM | WSMan}] [-Restart] [-WhatIf] [-WsmanAuthentication {Default | Basic | Negotiate | CredSSP | Digest
| Kerberos}] [<CommonParameters>]
DESCRIPTION
The Rename-Computer cmdlet renames the local computer or a remote computer. It renames one computer in each command.
This cmdlet was introduced in Windows PowerShell 3.0.
PARAMETERS
-ComputerName <String>
Renames the specified remote computer. The default is the local computer.
Type the NetBIOS name, an IP address, or a fully qualified domain name of a remote computer. To specify the local computer, type the computer
name, a dot (.), or localhost.
This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of Rename-Computer even if your computer
is not configured to run remote commands.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-DomainCredential <PSCredential>
Specifies a user account that has permission to connect to the domain. Explicit credentials are required to rename a computer that is joined
to a domain.
Type a user name, such as User01 or Domain01\\User01, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If
you type a user name, this cmdlet prompts you for a password.
To specify a user account that has permission to connect to the computer that is specified by the ComputerName parameter, use the
LocalCredential parameter.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Force [<SwitchParameter>]
Forces the command to run without asking for user confirmation.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-LocalCredential <PSCredential>
Specifies a user account that has permission to connect to the computer specified by the ComputerName parameter. The default is the current
user.
Type a user name, such as User01 or Domain01\\User01, or enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If
you type a user name, this cmdlet prompts you for a password.
To specify a user account that has permission to connect to the domain, use the DomainCredential parameter.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-NewName <String>
Specifies a new name for the computer. This parameter is required. The name cannot include control characters, leading or trailing spaces, or
any of the following characters: / \\\\ [ ].
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-PassThru [<SwitchParameter>]
Returns the results of the command. Otherwise, this cmdlet does not generate any output.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Protocol <String>
Specifies which protocol to use to rename the computer. The acceptable values for this parameter are: WSMan and DCOM. The default value is
DCOM.
This parameter was introduced in Windows PowerShell 3.0.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Restart [<SwitchParameter>]
Indicates that this cmdlet restarts the computer that was renamed. A restart is often required to make the change effective.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WsmanAuthentication <String>
Specifies the mechanism that is used to authenticate the user credentials when this cmdlet uses the WSMan protocol. The acceptable values for
this parameter are:
- Basic
- CredSSP
- Default
- Digest
- Kerberos
- Negotiate
The default value is Default.
For more information about the values of this parameter, see AuthenticationMechanism Enumerationhttp://go.microsoft.com/fwlink/?LinkID=235230
(http://go.microsoft.com/fwlink/?LinkID=235230) in the Microsoft Developer Network (MSDN) library.
Caution: Credential Security Service Provider (CredSSP) authentication, in which the user credentials are passed to a remote computer to be
authenticated, is designed for commands that require authentication on more than one resource, such as accessing a remote network share. This
mechanism increases the security risk of the remote operation. If the remote computer is compromised, the credentials that are passed to it
can be used to control the network session.
This parameter was introduced in Windows PowerShell 3.0.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
This cmdlet does not have parameters that take input by value. However, you can pipe the values of the ComputerName and NewName properties of
objects to this cmdlet.
OUTPUTS
Microsoft.PowerShell.Commands.ComputerChangeInfo
This cmdlet returns a ComputerChangeInfo object, if you specify the PassThru parameter. Otherwise, it does not return any output.
NOTES
Example 1: Rename the local computer
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: Rename a remote computer
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: Rename multiple computers
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, which is the value of the OldName
property, for the value of the ComputerName parameter. It specifiesthe new name, the value of the NewName property, for the value of the NewName
parameter. The command specifies domain credentials and uses Force and Restart to suppress all user prompts and restart each computer after it is
renamed.
RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=821620
Add-Computer
Remove-Computer
Reset-ComputerMachinePassword
Restart-Computer
Stop-Computer