ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Rename Windows Hostname from Command Line

    IT Discussion
    wmic powershell cmd windows windows 10 screenconnect
    8
    9
    2.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      If you need to change the hostname of a Windows box from the command line, the wmic tools make this a breeze. Use this pattern.

      wmic computersystem where name="%COMPUTERNAME%" call Rename Name="NEW-HOSTNAME"
      

      Using the where name="%COMPUTERNAME%" pattern lets you skip putting in the local machine name. The only piece you need to fill in is what your NEW-HOSTNAME should be.

      Confirmed as working on ScreenConnect, too.

      JaredBuschJ black3dynamiteB 2 Replies Last reply Reply Quote 7
      • JaredBuschJ
        JaredBusch @scottalanmiller
        last edited by

        @scottalanmiller said in Rename Windows Hostname from Command Line:

        Confirmed as working on ScreenConnect, too.

        This is not something I even think about checking. Because if it runs non-interactive from a command prompt or powershell, it can run via screenconnect. Simple as that.

        1 Reply Last reply Reply Quote 2
        • black3dynamiteB
          black3dynamite @scottalanmiller
          last edited by black3dynamite

          @scottalanmiller Why not use Rename-Computer instead from PowerShell?

          ObsolesceO 1 Reply Last reply Reply Quote 2
          • ObsolesceO
            Obsolesce @black3dynamite
            last edited by

            @black3dynamite said in Rename Windows Hostname from Command Line:

            @scottalanmiller Why not use Rename-Computer instead from PowerShell?

            That's how I do it... less to type, less to remember, faster than using GUI.

            1 Reply Last reply Reply Quote 1
            • ingmarkoecherI
              ingmarkoecher
              last edited by

              Can I assume that all of the above will not affect domain membership and rename the computer in the domain correctly as well?

              scottalanmillerS EddieJenningsE 2 Replies Last reply Reply Quote 0
              • D
                Darek Hamann
                last edited by

                The PowerShell way will definitely not affect the domain membership. As for the wmic method, I have not tried that a single time to confirm.

                1 Reply Last reply Reply Quote 1
                • scottalanmillerS
                  scottalanmiller @ingmarkoecher
                  last edited by

                  @ingmarkoecher said in Rename Windows Hostname from Command Line:

                  Can I assume that all of the above will not affect domain membership and rename the computer in the domain correctly as well?

                  We used the wmic on a domain, and it worked fine.

                  1 Reply Last reply Reply Quote 1
                  • EddieJenningsE
                    EddieJennings @ingmarkoecher
                    last edited by

                    @ingmarkoecher said in Rename Windows Hostname from Command Line:

                    Can I assume that all of the above will not affect domain membership and rename the computer in the domain correctly as well?

                    The add-computer cmdlet would be used for domain joining.

                    1 Reply Last reply Reply Quote 1
                    • gjacobseG
                      gjacobse
                      last edited by gjacobse

                      The batch file I have for one client is this:

                      powershell Rename-Computer -NewName "COMPUTER_NAME" -DomainCredential DOMAIN\ADMINUser -Restart
                      

                      Where COMPUTER_NAME to not exceed the 15 character limit

                      ETA:
                      I should add that this batch script start with installing Chocolatey package management tools, then the default applications,

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post