Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dmi3mis/435bf75a7505711f5b83397231131f76 to your computer and use it in GitHub Desktop.
Save dmi3mis/435bf75a7505711f5b83397231131f76 to your computer and use it in GitHub Desktop.
#The is almost the same like '05 SQL Server and client, domain joined.ps1' but installs an Exchange 2013 server instead
#of a SQL Server.
#
# IMPORTANT NOTE: Make sure you have installed at least the CU KB3206632 before installing Exchange 2016, this is a requirement.
# Refer to the introduction script '11 ISO Offline Patching.ps1' for creating a new ISO that contains patches.
#
# You will need 5 files to download before start this script
# 1. AutomatedLab latest https://github.com/AutomatedLab/AutomatedLab/releases
# Download msi and just install wherever folder you like. ( C:\LabSources for example )
# 2. Windows 10 Enterprise Eval https://www.microsoft.com/en-us/evalcenter/evaluate-windows-10-enterprise
# 3. Windows Server 2016 Datacenter Eval https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2016
# 4. Office 2013 iso (must be downloaded as ISO image en_office_professional_plus_2013_with_sp1_x86_and_x64_dvd_3928186.iso)
# 5. Exchange Server 2016 CU5 https://www.microsoft.com/en-us/download/details.aspx?id=54930
# Download all iso files to ISOs dir ( C:\LabSources\ISOs as example )
# 6 Windows Server 2016 latest Cumulative update for your build http://www.catalog.update.microsoft.com/Search.aspx?q=server%202016%20cumulative%20update
# For time writing file is windows10.0-kb4051033-x64_6e6a9d355d051a231e289a6d7931dd8f979f8d0c.msu
# Download update and put in OSUpdates folder ( C:\LabSources\OSUpdates as example )
$VerbosePreference = 'SilentlyContinue'
#$VerbosePreference = 'Continue'
$labName="testlab"
New-LabDefinition -Name $labName -DefaultVirtualizationEngine HyperV -VmPath "C:\Program Files\Microsoft Learning\LS-VMs"
#make the network definition
Add-LabVirtualNetworkDefinition -Name "Private Network" -AddressSpace 172.16.0.0/24
#and the domain definition with the domain admin account
Add-LabDomainDefinition -Name contoso.com -AdminUser Administrator -AdminPassword 'Pa$$w0rd'
Set-LabInstallationCredential -Username Administrator -Password 'Pa$$w0rd'
Add-LabIsoImageDefinition -Name Exchange2016 -Path $labSources\ISOs\ExchangeServer2016-x64-cu5.iso
Add-LabIsoImageDefinition -Name Office2013 -Path $labSources\ISOs\en_office_professional_plus_2013_with_sp1_x86_and_x64_dvd_3928186.iso
#defining default parameter values, as these ones are the same for all the machines
$PSDefaultParameterValues = @{
'Add-LabMachineDefinition:DomainName' = 'contoso.com'
'Add-LabMachineDefinition:OperatingSystem' = 'Windows Server 2016 SERVERDATACENTER'
'Add-LabMachineDefinition:AutoLogonDomainName' = 'contoso'
'Add-LabMachineDefinition:AutoLogonUserName' = 'Administrator'
'Add-LabMachineDefinition:AutoLogonPassword' = 'Pa$$w0rd'
'Add-LabMachineDefinition:Network' = 'Private Network'
'Add-LabMachineDefinition:DnsServer1' = '172.16.0.10'
'Add-LabMachineDefinition:Gateway' = '172.16.0.1'
}
#the first machine is the root domain controller
$roles = Get-LabMachineRoleDefinition -Role RootDC @{ DomainFunctionalLevel = 'Win2012R2'; ForestFunctionalLevel = 'Win2012R2' }
Add-LabMachineDefinition -Name LON-DC1 -Roles $roles -Memory 1GB -IpAddress 172.16.0.10 -UserLocale en-us
Add-LabMachineDefinition -Name LON-EX1 -Roles Exchange2016 -Memory 6GB -IpAddress 172.16.0.20 -UserLocale en-us
Add-LabMachineDefinition -Name LON-EX2 -Roles Exchange2016 -Memory 6GB -IpAddress 172.16.0.21 -UserLocale en-us
$roles = Get-LabMachineRoleDefinition -Role Office2013
Add-LabMachineDefinition -Name LON-CL1 -OperatingSystem 'Windows 10 Enterprise' -Memory 2GB -Roles $roles -IpAddress 172.16.0.25 -UserLocale en-us
Install-Lab -NetworkSwitches -BaseImages -VMs -Domains -StartRemainingMachines
#Exchange 2016 required at least kb3206632. Hence before installing Exchange 2016, the update is applied
#Alternativly, you can create an updated ISO as described in the introduction script '11 ISO Offline Patching.ps1'.
Install-LabSoftwarePackage -Path $labSources\OSUpdates\windows10.0-kb4051033-x64_6e6a9d355d051a231e289a6d7931dd8f979f8d0c.msu -ComputerName (Get-LabVM -Role Exchange2016) -Timeout 60
Install-Lab -Office2013
Invoke-LabCommand -ComputerName (Get-LabVM -Role Exchange2016) -ScriptBlock {restart-computer -force}
Install-Lab -Exchange2016 -DelayBetweenComputers 300
Show-LabDeploymentSummary -Detailed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment