Saturday, January 03, 2015

Adding Azure VM to Domain - Powershell

Its a few line of code to add your new VM as member computer of Active Directory in Windows Azure.



$domainName = "your domaincontroller name"
$username = "domain admin"
$password = "password"
Set-DnsClient -InterfaceAlias "Ethernet*" -ConnectionSpecificSuffix $domainName $securePassword =  ConvertTo-SecureString $password
    -AsPlainText
    -Force
$cred = New-Object System.Management.Automation.PSCredential($username, $securePassword)
Add-Computer -DomainName $domainName -Credential $cred -Restart –Force


save the above powershell script file (.ps1)

While creating the new virtual machine in Azure,on Virtual machine Configuration step,(3rd step) click on the "Custom Script" check box and choose the ps1 file from your local.
Adding azure vm to domain controller