Powershell Script to add Windows Server 2022 to a domain.


 Step by step instruction to add the server to a domain by powershell..

 Adding machine to the domain

Step 1: Go to Start - Type "powershell" - Right click and open as "Run as Administrator".

 

Step 2: Type the below command:

Add-Computer -domainname lab.local -Credential lab.local\Administrator -restart -force

  • lab.local - domain
  • lab.local\Administrator - domain admin

Step 3:  Enter the domain admin credential.

Server will be added to the domain after server restart

 Rename the Server name

Step 1: Go to Start - Type "powershell" - Right click and open as "Run as Administrator".

 

Step 2: Type the below command:

Rename-Computer -NewName W2022 -LocalCredential WIN-UT94OEC802B\Administrator -Passthru

  • W2022 - New Server name.
  • WIN-UT94OEC802B - Old Server Name.
  • WIN-UT94OEC802B\Administrator - Local Server Account.

Step 3:  Enter the domain admin credential.

Server Name will be changed after the server restart

Comments

Post a Comment