Creating a Lab on Windows Azure – When creating a new server it should be part of this domain
We are nearly done with our Domain related activities. Now we need to make sure that all the Virtual Machines we create are part of same Active Directory. This will help us to manage the server and users in domain. In number of Demos we need a domain (AD), so we have met the most important pre-requisites.
- You need to copy below script into a notepad and save it as join.PS1
///// SCRIPT START HERE ////
$domainName = “type domain name here e.g. demo.com. It should be in quotes”
$username = “type domain\username e.g. demo\user1. It should be in quotes”
$password = “type password of above user e.g. 213@jjj. It should be in quotes”
$securePass = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($username, $securePass)
Add-Computer -DomainName $domainName -Credential $cred -Restart –Force
////// SCRIPT END HERE ////
- Login to your Azure Subscription Portal site https://manage.windowsazure.com
- Select “Virtual Machines” from left menu and select “Create a Virtual Machine”
- Under “Virtual Machine” select “From Gallery”
- On the Choose an Image screen select “Windows server 2012 R2” and select Next
- Type the Machines necessary details like Hardware configuration, Machine name, username and password
- Now we have an important step in the process. Select the DEMONETWORK you created in Region/Affinity Group/Virtual Network. Make sure our Virtual network name is selected in Virtual Network Subnet. Click on Next
- Now comes the most important step, we need to select Custom Script on this page and select the Join.ps1 script we just created. Click Finish
- You will observer that your machine will reboot during the initialization process.
- Now when the machine is created, Open Server Manager and you will observe it is already part of Demo domain. On the domain controller in “Active Directory users and computers” you should be able to see the newly added
Note: In some rare scenario, the new computer may not get added to the domain. In that case, please run above PowerShell command line by line and the computer would be added to domain.