Search code examples
powershellrenamehostname

Rename machine by IP (not hostname) in powershell


I'm dealing with a situation where there are 2 machines with the same hostname and different IPs. One of them needs to be renamed. I found that machine can be renamed remotely using the next command:

Rename-Computer -ComputerName "Srv01" -NewName "Server001" -LocalCredential Srv01\Admin01 -DomainCredential Domain01\Admin01 -Force -PassThru

But this one is accepting hostname not IP. Any help would be appreciated.


Solution

  • From the docs:

    -ComputerName

    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.