Skip to content
Open
49 changes: 25 additions & 24 deletions active-directory-new-domain-with-data/CallingScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,59 @@

# Install the Azure Resource Manager modules from PowerShell Gallery
# Takes a while to install 28 modules
Install-Module AzureRM -Force -Verbose
Install-AzureRM
# Install-Module Az -Force -Verbose

# Install the Azure Service Management module from PowerShell Gallery
Install-Module Azure -Force -Verbose
# # Install the Azure Service Management module from PowerShell Gallery
# Install-Module Azure -Force -Verbose

# Import AzureRM modules for the given version manifest in the AzureRM module
Import-AzureRM -Verbose
# # Import Az modules for the given version manifest in the Az module
# Import-Module Az -Verbose

# Import Azure Service Management module
Import-Module Azure -Verbose
# # Import Azure Service Management module
# Import-Module Azure -Verbose

# Authenticate to your Azure account
Login-AzureRmAccount
Login-AzAccount

# Adjust the 'yournamehere' part of these three strings to
# something unique for you. Leave the last two characters in each.
$URI = 'https://raw.githubusercontent.com/GoateePFE/AzureRM/master/active-directory-new-domain-with-data/azuredeploy.json'
$Location = 'east us'
$rgname = 'yournamehererg'
$saname = 'yournameheresa' # Lowercase required
$addnsName = 'yournameheread' # Lowercase required
$URI = 'https://raw.githubusercontent.com/cloudwidth/ADDS-with-Data/master/active-directory-new-domain-with-data/azuredeploy.json'
$Location = 'South Central US'
$rgname = 'RG-ActiveDirectory'
$namePrefix = 'Cloudwidth' # cannot start with numbers
$addnsName = ($namePrefix).ToLower() # Lowercase required


# Check that the public dns $addnsName is available
if (Test-AzureRmDnsAvailability -DomainNameLabel $addnsName -Location $Location)
if (Test-AzDnsAvailability -DomainNameLabel $addnsName -Location $Location)
{ 'Available' } else { 'Taken. addnsName must be globally unique.' }


# Create the new resource group. Runs quickly.
New-AzureRmResourceGroup -Name $rgname -Location $Location
New-AzResourceGroup -Name $rgname -Location $Location

# Parameters for the template and configuration
$MyParams = @{
newStorageAccountName = $saname
location = 'East US'
domainName = 'alpineskihouse.com'
location = $Location
domainName = ($namePrefix + ".com") # The maximum length is 15 characters
addnsName = $addnsName
namePrefix = $namePrefix
}

# Splat the parameters on New-AzureRmResourceGroupDeployment
# Splat the parameters on New-AzResourceGroupDeployment
$SplatParams = @{
TemplateUri = $URI
ResourceGroupName = $rgname
TemplateParameterObject = $MyParams
Name = 'AlpineSkiHouseForest'
Name = ($namePrefix + 'Forest')
}

# This takes ~30 minutes
# One prompt for the domain admin password
New-AzureRmResourceGroupDeployment @SplatParams -Verbose
New-AzResourceGroupDeployment @SplatParams -Verbose

# Find the VM IP and FQDN
$PublicAddress = (Get-AzureRmPublicIpAddress -ResourceGroupName $rgname)[0]
$PublicAddress = (Get-AzPublicIpAddress -ResourceGroupName $rgname)[0]
$IP = $PublicAddress.IpAddress
$FQDN = $PublicAddress.DnsSettings.Fqdn

Expand All @@ -75,4 +76,4 @@ Start-Process -FilePath mstsc.exe -ArgumentList "/v:$IP"
# Users root container has test users and populated test groups

# Delete the entire resource group when finished
Remove-AzureRmResourceGroup -Name $rgname -Force -Verbose
Remove-AzResourceGroup -Name $rgname -Force -Verbose
Loading