Skip to content

Instantly share code, notes, and snippets.

@nyanhp
Created November 24, 2017 10:44
Show Gist options
  • Save nyanhp/83d69c87d75b74b515b87be213ce3557 to your computer and use it in GitHub Desktop.
Save nyanhp/83d69c87d75b74b515b87be213ce3557 to your computer and use it in GitHub Desktop.
SQL Installation Customizations
$labName = 'Test5'
#create an empty lab template and define where the lab XML files and the VMs will be stored
New-LabDefinition -Name $labName -DefaultVirtualizationEngine Azure
Add-LabAzureSubscription -Path D:\myazuresettings.json -DefaultLocationName 'west europe'
#make the network definition
Add-LabVirtualNetworkDefinition -Name $labName -AddressSpace 192.168.71.0/24
#and the domain definition with the domain admin account
Add-LabDomainDefinition -Name test2.net -AdminUser Install -AdminPassword Somepass1
#these images are used to install the machines
Add-LabIsoImageDefinition -Name SQLServer2014 -Path $labSources\ISOs\en_sql_server_2014_enterprise_edition_with_service_pack_2_x64_dvd_8962401.iso
Set-LabInstallationCredential -Username Install -Password Somepass1
#defining default parameter values, as these ones are the same for all the machines
$PSDefaultParameterValues = @{
'Add-LabMachineDefinition:Network' = $labName
'Add-LabMachineDefinition:ToolsPath'= "$labSources\Tools"
'Add-LabMachineDefinition:IsDomainJoined'= $true
'Add-LabMachineDefinition:DnsServer1'= '192.168.71.10'
'Add-LabMachineDefinition:OperatingSystem'= 'Windows Server 2016 SERVERDATACENTER'
'Add-LabMachineDefinition:DomainName' = 'test2.net'
}
# Role definitions
$dcRole = Get-LabMachineRoleDefinition -Role RootDC @{ DomainFunctionalLevel = 'Win2008'; ForestFunctionalLevel = 'Win2008' }
<#
The role properties map to the setup parameters of SQL Server
Since the domain is specified for both sqlPower and JamesBond, both users will automatically be created during SQL server setup.
The collection will be set accordingly, and the Sample Database for SQL Server 2014 will be installed
#>
$customProperties = @{
Features = 'SQL,AS'
InstanceName = 'PSFTW'
Collation = 'Japanese_Bushu_Kakusu_100_CS_AS_KS_WS'
SQLSvcAccount = 'test2\sqlPOWER'
SQLSvcPassword = '555Nase!1'
AgtSvcAccount = 'test2\JamesBond'
AgtSvcPassword = '555Nase!1'
InstallSampleDatabase = 'true'
}
$sqlRole = Get-LabMachineRoleDefinition -Role SQLServer2014 -Properties $customProperties
Add-LabMachineDefinition -Name T2DC1 -Memory 512MB -IpAddress 192.168.71.10 -Roles $dcRole -PostInstallationActivity $postInstallActivity
Add-LabMachineDefinition -Name T2Sql1 -Memory 1GB -Processors 2 -IpAddress 192.168.71.51 -Roles $sqlRole
Add-LabMachineDefinition -Name T2Sql2 -Memory 1GB -Processors 2 -IpAddress 192.168.71.52 -Roles $sqlRole
Install-Lab
Show-LabDeploymentSummary -Detailed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment