Last active
July 12, 2023 19:14
-
-
Save dmi3mis/cab72be963d9662eb8c886fb5a35cb74 to your computer and use it in GitHub Desktop.
Powershell script to automaticaly deploy lab with dc, exchange 2016 servers, and windows 10. Connected to internet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create an empty lab template and define path to files where VMs will be stored | |
New-LabDefinition -Name 'Ex2013lab' -DefaultVirtualizationEngine HyperV -VmPath "C:\Program Files\Microsoft Learning\Ex2013Lab\" # If you want to place vm files in custom dir add -VmPath "drive:\path\to\directory" | |
#defining default parameter values, as these ones are the same for all the machines | |
$PSDefaultParameterValues = @{ | |
'Add-LabMachineDefinition:DomainName' = 'adatum4.ml' | |
'Add-LabMachineDefinition:OperatingSystem' = 'Windows Server 2012 R2 Datacenter (Server with a GUI)' | |
'Add-LabMachineDefinition:UserLocale' = 'en-US' | |
} | |
#Network Definition | |
Add-LabVirtualNetworkDefinition -Name "Private Network" -AddressSpace 172.16.0.0/16 -HyperVProperties @{SwitchType = 'Internal'} | |
Set-LabInstallationCredential -Username Administrator -Password 'Pa$$w0rd' | |
Add-LabDomainDefinition -Name "adatum4.ml" -AdminUser Administrator -AdminPassword 'Pa$$w0rd' | |
Add-LabIsoImageDefinition -Name Office2016 -Path $labSources\ISOs\en_office_professional_plus_2016_x86_x64_dvd_6962141.iso | |
$r = Get-LabPostInstallationActivity -CustomRole Exchange2013 -Properties @{ OrganizationName = 'Adatum2 Exchange Organization' } | |
Add-LabMachineDefinition -Name DC1 -Memory 1GB -IpAddress 172.16.0.110 -DnsServer1 172.16.0.110 -DnsServer2 172.16.0.111 -Gateway 172.16.0.1 -MinMemory 512MB -MaxMemory 2GB -Roles RootDC | |
Add-LabMachineDefinition -Name DC2 -Memory 1GB -IpAddress 172.16.0.111 -DnsServer1 172.16.0.110 -DnsServer2 172.16.0.111 -Gateway 172.16.0.1 -MinMemory 512MB -MaxMemory 2GB -Roles DC | |
Add-LabMachineDefinition -Name MBX1 -Memory 8GB -IpAddress 172.16.0.120 -DnsServer1 172.16.0.110 -DnsServer2 172.16.0.111 -Gateway 172.16.0.1 -PostInstallationActivity $r | |
Add-LabMachineDefinition -Name MBX2 -Memory 8GB -IpAddress 172.16.0.121 -DnsServer1 172.16.0.110 -DnsServer2 172.16.0.111 -Gateway 172.16.0.1 -PostInstallationActivity $r | |
Add-LabMachineDefinition -Name CL1 -Memory 1GB -IpAddress 172.16.0.125 -DnsServer1 172.16.0.110 -DnsServer2 172.16.0.111 -Gateway 172.16.0.1 -OperatingSystem 'Windows 10 Enterprise' -MinMemory 512MB -MaxMemory 5GB -Roles Office2016 | |
Add-LabMachineDefinition -Name CL2 -Memory 1GB -IpAddress 172.16.0.126 -DnsServer1 172.16.0.110 -DnsServer2 172.16.0.111 -Gateway 172.16.0.1 -OperatingSystem 'Windows 10 Enterprise' -MinMemory 512MB -MaxMemory 5GB -Roles Office2016 | |
Install-Lab -NetworkSwitches | |
Install-Lab -BaseImages -VMs -Domains -StartRemainingMachines | |
Install-Lab -Office2016 | |
Install-Lab -PostInstallations | |
Restart-LabVM -ComputerName MBX1 -Wait | |
Restart-LabVM -ComputerName MBX2 | |
Show-LabDeploymentSummary -Detailed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$azureResourceManagerProfile = "path_to_file" # IF YOU DO NOT HAVE A PROFILE FILE, CALL Save-AzureRmContext | |
$azureDefaultLocation = 'West Europe' #COMMENT OUT -DefaultLocationName BELOW TO USE THE FASTEST LOCATION | |
New-LabDefinition -Name 'ExchLab' -DefaultVirtualizationEngine Azure | |
Add-LabAzureSubscription -Path $azureResourceManagerProfile -DefaultLocationName $azureDefaultLocation | |
#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 Datacenter (Desktop Experience)' | |
'Add-LabMachineDefinition:UserLocale' = 'en-US' | |
} | |
Set-LabInstallationCredential -Username install -Password 'Pa55w.rd' | |
Add-LabDomainDefinition -Name contoso.com -AdminUser install -AdminPassword 'Pa55w.rd' | |
#make the network definition | |
Add-LabVirtualNetworkDefinition -Name Network1 -AddressSpace 172.16.0.0/24 -AzureProperties @{ DnsServers = '172.16.0.10'; LocationName = $azureDefaultLocation } | |
Add-LabIsoImageDefinition -Name Office2016 -Path "$labSources\ISOs\en_office_professional_plus_2016_x86_x64_dvd_6962141.iso" | |
$r = Get-LabPostInstallationActivity -CustomRole Exchange2016 -Properties @{ OrganizationName = 'ExchOrg' } | |
Add-LabMachineDefinition -Name ExchLabDC1 -Memory 1GB -IpAddress 172.16.0.10 -Network Network1 -Roles RootDC | |
Add-LabMachineDefinition -Name ExchLabEX1 -Memory 8GB -IpAddress 172.16.0.20 -Network Network1 -PostInstallationActivity $r -AzureProperties @{ RoleSize = 'Standard_D2_v3' } | |
Add-LabMachineDefinition -Name ExchLabEX2 -Memory 8GB -IpAddress 172.16.0.21 -Network Network1 -PostInstallationActivity $r -AzureProperties @{ RoleSize = 'Standard_D2_v3' } | |
Add-LabMachineDefinition -Name ExchLabCL1 -Memory 2GB -IpAddress 172.16.0.25 -Network Network1 -OperatingSystem 'Windows 10 Enterprise' -Roles Office2016 | |
Install-Lab -NetworkSwitches -BaseImages -VMs -Domains -StartRemainingMachines | |
Install-Lab -Office2016 | |
Install-Lab -PostInstallations | |
Restart-LabVM -ComputerName ExchLabEX1 -Wait | |
Restart-LabVM -ComputerName ExchLabEX2 -Wait | |
Show-LabDeploymentSummary -Detailed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Before Using This script you must | |
#1. add support of AutomatedLab Repo https://github.com/AutomatedLab/AutomatedLab support to your computer | |
#Install-PackageProvider -Name Nuget -ForceBootstrap -Force -ErrorAction Stop | Out-Null | |
#Install-Module -Name AutomatedLab -AllowClobber -Force -ErrorAction Stop | |
#Import-Module -Name AutomatedLab -ErrorAction Stop | |
#New-LabSourcesFolder -DriveLetter C -Force -ErrorAction Stop # Where "C" is a drive letter, where LabSources folder will be located. | |
#2.Create HyperV internal Virtual Switch with name "Internal" | |
#new-vmswitch -name "Internal" -SwitchType Internal | |
#3. Enable nat in Internal Switch | |
# New-NetIPAddress -IPAddress 172.16.0.1 -PrefixLength 16 -InterfaceIndex $($(get-netadapter -Name "vEthernet (Internal)").ifIndex) | |
# New-NetNat -Name NatNetwork -InternalIPInterfaceAddressPrefix 172.16.0.0/16 | |
#create an empty lab template and define path to files where VMs will be stored | |
New-LabDefinition -Name 'LabEx2013' -DefaultVirtualizationEngine HyperV # If you want to place vm files in custom dir add -VmPath "drive:\path\to\directory" | |
#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 2012 R2 Datacenter (Server with a GUI)' | |
'Add-LabMachineDefinition:UserLocale' = 'en-US' | |
} | |
#Network Definition | |
Add-LabVirtualNetworkDefinition -Name "Private Network" -AddressSpace 172.16.0.0/16 -HyperVProperties @{SwitchType = 'Internal'} | |
Set-LabInstallationCredential -Username Administrator -Password 'Pa$$w0rd' | |
Add-LabDomainDefinition -Name "contoso.com" -AdminUser Administrator -AdminPassword 'Pa$$w0rd' | |
Add-LabIsoImageDefinition -Name Office2016 -Path $labSources\ISOs\en_office_professional_plus_2016_x86_x64_dvd_6962141.iso | |
$r = Get-LabPostInstallationActivity -CustomRole Exchange2013 -Properties @{ OrganizationName = 'ExchOrg' } | |
Add-LabMachineDefinition -Name Ex2013DC1 -Memory 1GB -IpAddress 172.16.0.110 -DnsServer1 172.16.0.110 -Gateway 172.16.0.1 -MinMemory 512MB -MaxMemory 2GB -Roles RootDC | |
Add-LabMachineDefinition -Name Ex2013MBX1 -Memory 8GB -IpAddress 172.16.0.120 -DnsServer1 172.16.0.110 -Gateway 172.16.0.1 -PostInstallationActivity $r | |
Add-LabMachineDefinition -Name Ex2013MBX2 -Memory 8GB -IpAddress 172.16.0.121 -DnsServer1 172.16.0.110 -Gateway 172.16.0.1 -PostInstallationActivity $r | |
Add-LabMachineDefinition -Name Ex2013CL1 -Memory 1GB -IpAddress 172.16.0.125 -DnsServer1 172.16.0.110 -Gateway 172.16.0.1 -OperatingSystem 'Windows 10 Enterprise' -MinMemory 512MB -MaxMemory 5GB -Roles Office2016 | |
Install-Lab -NetworkSwitches | |
Install-Lab -BaseImages -VMs -Domains -StartRemainingMachines | |
Install-Lab -Office2016 | |
Install-Lab -PostInstallations | |
Restart-LabVM -ComputerName Ex2013MBX1 -Wait | |
Restart-LabVM -ComputerName Ex2013MBX2 | |
Show-LabDeploymentSummary -Detailed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Before Using This script you must | |
#1. add https://github.com/AutomatedLab/AutomatedLab support to your computer | |
#Install-PackageProvider -Name Nuget -ForceBootstrap -Force -ErrorAction Stop | |
#Install-Module -Name AutomatedLab -AllowClobber -Force -ErrorAction Stop | |
#Import-Module -Name AutomatedLab -ErrorAction Stop | |
#New-LabSourcesFolder -DriveLetter C -Force -ErrorAction Stop | |
#2.Create HyperV internal Virtual Switch with name "Private Network" | |
#new-vmswitch -name "Private Network" -SwitchType Internal | |
#3. Enable nat in Internal Switch | |
# New-NetIPAddress -IPAddress 172.16.0.1 -PrefixLength 16 -InterfaceIndex $($(get-netadapter -Name "vEthernet (Private Network)").ifIndex) | |
# New-NetNat -Name NatNetwork -InternalIPInterfaceAddressPrefix 172.16.0.0/16 | |
#create an empty lab template and define path to files where VMs will be stored | |
New-LabDefinition -Name 'Ex2016' -DefaultVirtualizationEngine HyperV -VmPath "C:\vms\Ex2016" # If you want to place vm files in custom dir add -VmPath "drive:\path\to\directory" | |
#defining default parameter values, as these ones are the same for all the machines | |
$PSDefaultParameterValues = @{ | |
'Add-LabMachineDefinition:DomainName' = 'excompany№.ml' | |
'Add-LabMachineDefinition:OperatingSystem' = 'Windows Server 2016 Datacenter (Desktop Experience)' | |
'Add-LabMachineDefinition:UserLocale' = 'en-US' | |
} | |
#Network Definition | |
Add-LabVirtualNetworkDefinition -Name "Private Network" -AddressSpace 172.16.0.0/16 -HyperVProperties @{SwitchType = 'Internal'} | |
Set-LabInstallationCredential -Username Administrator -Password 'Pa55w.rd' | |
Add-LabDomainDefinition -Name excompany№.ml -AdminUser Administrator -AdminPassword 'Pa55w.rd' | |
Add-LabIsoImageDefinition -Name Office2016 -Path $labSources\ISOs\en_office_professional_plus_2016_x86_x64_dvd_6962141.iso | |
$r = Get-LabPostInstallationActivity -CustomRole Exchange2016 -Properties @{ OrganizationName = 'ExCompanyOrg' } | |
Add-LabMachineDefinition -Name DC1 -Memory 1GB -IpAddress 172.16.1.10 -DnsServer1 172.16.1.10 -Gateway 172.16.0.1 -MinMemory 512MB -MaxMemory 2GB -Roles RootDC | |
Add-LabMachineDefinition -Name EX1 -Memory 8GB -IpAddress 172.16.1.20 -DnsServer1 172.16.1.10 -Gateway 172.16.0.1 -PostInstallationActivity $r | |
Add-LabMachineDefinition -Name EX2 -Memory 8GB -IpAddress 172.16.1.21 -DnsServer1 172.16.1.10 -Gateway 172.16.0.1 -PostInstallationActivity $r | |
Add-LabMachineDefinition -Name CL1 -Memory 1GB -IpAddress 172.16.1.25 -DnsServer1 172.16.1.10 -Gateway 172.16.0.1 -OperatingSystem 'Windows 10 Enterprise' -MinMemory 512MB -MaxMemory 5GB -Roles Office2016 | |
Add-LabMachineDefinition -Name CL2 -Memory 1GB -IpAddress 172.16.1.26 -DnsServer1 172.16.1.10 -Gateway 172.16.0.1 -OperatingSystem 'Windows 10 Enterprise' -MinMemory 512MB -MaxMemory 5GB -Roles Office2016 | |
Install-Lab -NetworkSwitches | |
Install-Lab -BaseImages -VMs -Domains -StartRemainingMachines | |
Install-Lab -Office2016 | |
Install-Lab -PostInstallations | |
Restart-LabVM -ComputerName EX1 -Wait | |
Restart-LabVM -ComputerName EX2 | |
Show-LabDeploymentSummary -Detailed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# postinstall draft | |
# 1. Accepted Domain | |
# 2. CAS | |
mail A 123.123.123.123 | |
autodiscover A 123.123.123.123 | |
Configure the SCP for Autodiscover | |
Get-ClientAccessService | format-list name,auto* | |
Get-ClientAccessService | Set-ClientAccessService –AutoDiscoverServiceInternalUri https://mail.corp2.dmi3lab.ml/Autodiscover/Autodiscover.xml | |
Get-OwaVirtualDirectory | Set-OwaVirtualDirectory -InternalUrl https://mail.corp2.dmi3lab.ml/owa -ExternalUrl https://mail.corp2.dmi3lab.ml/owa | |
Get-EcpVirtualDirectory | Set-EcpVirtualDirectory -InternalUrl https://mail.corp2.dmi3lab.ml/ecp -ExternalUrl https://mail.corp2.dmi3lab.ml/ecp | |
Get-OabVirtualDirectory | Set-OabVirtualDirectory -InternalUrl https://mail.corp2.dmi3lab.ml/OAB -ExternalUrl https://mail.corp2.dmi3lab.ml/OAB | |
Get-MapiVirtualDirectory |Set-MapiVirtualDirectory -InternalUrl https://mail.corp2.dmi3lab.ml/mapi -ExternalUrl https://mail.corp2.dmi3lab.ml/mapi | |
Get-PowerShellVirtualDirectory |Set-PowerShellVirtualDirectory -InternalUrl http://mail.corp2.dmi3lab.ml/powershell -ExternalUrl http://mail.corp2.dmi3lab.ml/powershell | |
Get-WebServicesVirtualDirectory |Set-WebServicesVirtualDirectory -InternalUrl https://mail.corp2.dmi3lab.ml/EWS/Exchange.asmx -ExternalUrl https://mail.corp2.dmi3lab.ml/EWS/Exchange.asmx | |
Get-OutlookAnywhere |Set-OutlookAnywhere -InternalHostname mail.corp2.dmi3lab.ml -ExternalHostname mail.corp2.dmi3lab.ml -InternalClientsRequireSsl $true -ExternalClientsRequireSsl $true -InternalClientAuthenticationMethod Negotiate -ExternalClientAuthenticationMethod Negotiate | |
download | |
https://github.com/win-acme/win-acme/releases/download/v2.2.5.1541/win-acme.v2.2.5.1541.x64.pluggable.zip | |
read | |
https://www.win-acme.com/manual/advanced-use/examples/exchange | |
start | |
c:\win-acme.v2.2.5.1541.x64.pluggable>wacs.exe --source manual --host mail.corp2.dmi3lab.ml,autodiscover.corp2.dmi3lab.ml --certificatestore My --acl-fullcontrol "network service,administrators" --installation iis,script --installationsiteid 1 --script "./Scripts/ImportExchange.v2.ps1" --scriptparameters "'{CertThumbprint}' 'IIS,SMTP,IMAP' 1 '{CacheFile}' '{CachePassword}' '{CertFriendlyName}'" | |
# 3. MailBox Databases |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment