Rename Windows Server 2019 using PowerShell
There are several ways to rename a machine, but be sure to do it before putting the server in a production environment. The easiest way is to do it right after creating the server, by right-clicking on the start menu, choosing “System” and then clicking on “Rename this PC”. Another way is in Server Manager, go into “Local Server” and click on the name after “Computer name”, then click on “Change”. The third is through PowerShell, follow the steps below.
If you run into problems, I am always happy to help. You can find me on LinkedIn by following the link at the top of the page.
Tonje
Open PowerShell as administrator, right click and choose “Run as administrator“

Let’s see the name we start with, run “$env:COMPUTERNAME”

To change the computer name, run “Rename-Computer -NewName NAMEOFYOURCHOICE -Restart”
This will restart the machine

After the machine has restarted, open PowerShell again and run “$env:COMPUTERNAME”

This Windows Server 2019 now has a new name
Sources
All images: Solberg, 2022