Skip to content

Instantly share code, notes, and snippets.

@rupertbenbrook
Created April 29, 2017 16:47
Show Gist options
  • Save rupertbenbrook/c2c62de02ba685c1624c056c55cf3ade to your computer and use it in GitHub Desktop.
Save rupertbenbrook/c2c62de02ba685c1624c056c55cf3ade to your computer and use it in GitHub Desktop.
Creates the basic Office 365 DNS records in an Azure DNS zone
param (
[Parameter(Mandatory=$true)]
$ResourceGroupName,
[Parameter(Mandatory=$true)]
$ZoneName,
$TTL = 3600
)
$zoneNameDash = $ZoneName.Replace('.', '-')
# CNAME
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "autodiscover" -RecordType CNAME -DnsRecords (New-AzureRmDnsRecordConfig -Cname "autodiscover.outlook.com")
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "enterpriseenrollment" -RecordType CNAME -DnsRecords (New-AzureRmDnsRecordConfig -Cname "enterpriseenrollment.manage.microsoft.com")
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "enterpriseregistration" -RecordType CNAME -DnsRecords (New-AzureRmDnsRecordConfig -Cname "enterpriseregistration.windows.net")
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "lyncdiscover" -RecordType CNAME -DnsRecords (New-AzureRmDnsRecordConfig -Cname "webdir.online.lync.com")
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "msoid" -RecordType CNAME -DnsRecords (New-AzureRmDnsRecordConfig -Cname "clientconfig.microsoftonline-p.net")
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "sip" -RecordType CNAME -DnsRecords (New-AzureRmDnsRecordConfig -Cname "sipdir.online.lync.com")
# SRV
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "_sipfederationtls._tcp" -RecordType SRV -DnsRecords (New-AzureRmDnsRecordConfig -Priority 100 -Weight 1 -Port 5061 -Target "sipfed.online.lync.com")
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "_sip._tls" -RecordType SRV -DnsRecords (New-AzureRmDnsRecordConfig -Priority 100 -Weight 1 -Port 443 -Target "sipdir.online.lync.com")
# TXT
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "@" -RecordType TXT -DnsRecords (New-AzureRmDnsRecordConfig -Value "v=spf1 include:spf.protection.outlook.com -all")
# MX
New-AzureRmDnsRecordSet -ResourceGroupName $ResourceGroupName -ZoneName $ZoneName -TTL $TTL -Name "@" -RecordType MX -DnsRecords (New-AzureRmDnsRecordConfig -Exchange "$zoneNameDash.mail.protection.outlook.com" -Preference 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment