Syntax
Parameter Set: Default
Rename-Computer [-NewName] <String> [-ComputerName <String> ] [-DomainCredential <PSCredential> ] [-Force] [-LocalCredential <PSCredential> ] [-PassThru] [-Restart] [-Confirm] [-WhatIf] [ <CommonParameters>]
Reference:https://technet.microsoft.com/en-us/library/hh849792.aspx
Change Single comupter name:
Using Domain Credentials:
Rename-Computer -NewName WIN-SP01 -DomainCredential CORP\Administrator -Restart #-Please Change computer name and domain credentials
Using Domain and Local credentials:
Rename-Computer -ComputerName WIN-89C5DXRG -NewName WIN-SP01 -LocalCredential "WIN-89C5DXRG\Administrator" -DomainCredential "CORP\Administrator" -Force -PassThru -Restart
Parameter Set: Default
Rename-Computer [-NewName] <String> [-ComputerName <String> ] [-DomainCredential <PSCredential> ] [-Force] [-LocalCredential <PSCredential> ] [-PassThru] [-Restart] [-Confirm] [-WhatIf] [ <CommonParameters>]
Reference:https://technet.microsoft.com/en-us/library/hh849792.aspx
Change Single comupter name:
Using Domain Credentials:
Rename-Computer -NewName WIN-SP01 -DomainCredential CORP\Administrator -Restart #-Please Change computer name and domain credentials
Using Domain and Local credentials:
Rename-Computer -ComputerName WIN-89C5DXRG -NewName WIN-SP01 -LocalCredential "WIN-89C5DXRG\Administrator" -DomainCredential "CORP\Administrator" -Force -PassThru -Restart
Change/Re-Name multiple computers:
$a = Import-Csv C:\Serverslist.csv -Header OldName, NewName #-Change csv file path
Foreach ( $Server in $a )
{
Rename-Computer -ComputerName $Server.OldName -NewName $Server.NewName -DomainCredential Domain01\Admin01 -Force -Restart
write-Host "$Server Name has been changed successfully!!" -ForegroundColor "Green" -BackgroundColor "Black"
}
else
{
write-Host "Unable to connect remote server $Server" -ForegroundColor "Yellow" -BackgroundColor "Red"
}