Installing Active Directory on Azure VM

Posted: November 18, 2016 in Azure

In one of previous posts i installed VM with Windows Server 2016.It currently have dynamic IP address,so we need to set a static one.

Installing Azure PowerShell

Azure PowerShell is a set of modules that provide cmdlets to manage Azure with Windows PowerShell. You can use the cmdlets to create, test, deploy, and manage solutions and services delivered through the Azure platform.I used Web Platform Installer.It’s tool that allows you to download and install web and cloud tools.




Now start powershell as Administrator


You’ll be prompted for Azure credentials



Now,when we are logged in to Azure,we can finally set VM’s IP and DNS address

$RGname = 'test_network_resource_group' #VM and NIC RG
$VNetRG = 'test_network_resource_group' #Virt Net RG
$VMName = 'server-2016' #VM Name
$NICName = 'server-2016784' #NIC Name
$VNetName = 'test_network' #Virt Net name
$TarSubnetName = 'default' #Target subnet name
$VM = Get-AzureRmVM -Name $VMName -ResourceGroupName $RGname
$VNET = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $VNetRG
$TarSubnet = Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $VNET -Name $TarSubnetName
$NIC = Get-AzureRmNetworkInterface -Name $NICName -ResourceGroupName $RGname
$NIC.IpConfigurations[0].Subnet.Id = $TarSubnet.Id
Set-AzureRmNetworkInterface -NetworkInterface $NIC

#Once the subnet has been set and that applied can apply the static IP address
$NIC = Get-AzureRmNetworkInterface -Name $NICName -ResourceGroupName $RGname
$NIC.IpConfigurations[0].PrivateIpAddress = ‘' #set IP address
$NIC.IpConfigurations[0].PrivateIPAllocationMethod = 'Static'
$NIC.DnsSettings.DnsServers = '' #Set preferred DNS server 
Set-AzureRmNetworkInterface -NetworkInterface $NIC

Installing AD on Azure VM

I logged on to VM and set Primary DNS suffix

netdom computername server-2016 /
netdom computername server-2016 /

After reboot,i installed AD service:

Install-windowsfeature ad-domain-services -IncludeManagementTools
Import-Module ADDSDeployment
Install-ADDSForest `
-CreateDnsDelegation:$false `
-DatabasePath "C:\Windows\NTDS" `
-DomainMode "Win2012R2" `
-DomainName "" `
-DomainNetbiosName "TEST" `
-ForestMode "Win2012R2" `
-InstallDns:$true `
-LogPath "C:\Windows\NTDS" `
-NoRebootOnCompletion:$false `
-SysvolPath "C:\Windows\SYSVOL" `

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s