This commit is contained in:
Troy Ault 2017-08-17 14:45:16 -04:00
Родитель 516ba867f4
Коммит f82a373406
12 изменённых файлов: 430 добавлений и 0 удалений

36
utility/LabInaBox/.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,36 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File",
"script": "${file}",
"args": [],
"cwd": "${file}"
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File w/Args Prompt",
"script": "${file}",
"args": [
"${command:SpecifyScriptArgs}"
],
"cwd": "${file}"
},
{
"type": "PowerShell",
"request": "attach",
"name": "PowerShell Attach to Host Process",
"processId": "${command:PickPSHostProcess}",
"runspaceId": 1
},
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Interactive Session",
"cwd": "${workspaceRoot}"
}
]
}

Просмотреть файл

@ -0,0 +1,25 @@
{
"ScriptLocation": "D:\\LabInaBox\\Scripts",
"DSCResourceDest": "C:\\Program Files\\WindowsPowerShell\\Modules",
"DSCResourceSource":"D:\\LabInaBox\\DSCResources",
"ParentFolderPath": "C:\\LabInaBox\\ParentVMDisks",
"ParentFolderPathSource":"D:\\LabInaBox\\ParentVMDisks",
"ChildFolderPath": "E:\\LabInaBox\\ChildVMDisks\\DD",
"ISOFolderPath" : "D:\\LabInaBox\\ISO",
"DomainJoinPath": "E:\\LabInaBox\\ChildVMDisks\\DD\\DomainJoin",
"DCMachineName": "DD-DC",
"DeveloperMachine" : "DD-Dev",
"ServertoQueue": ["DD-SQL1","DD-SQL2"],
"ServerConfig": "SQLStandAlone",
"DomainJoinServer": ["DD-DSC","DD-SQL1","DD-SQL2","DD-Dev"],
"localAdminPass": "P@ssw0rd",
"domainAdminPass": "P@ssw0rd",
"sysPrepDriveName": "Win16SysPrepFinal.vhdx",
"DCSysPrepDriveName": "Win16SysPrepFinal.vhdx",
"SwitchName": "GuestToGuest220",
"domainname": "DD-Lab",
"domainExtention": ".com",
"DomainIpAddress":"192.168.220.1",
"DHCPScopeIpStart": "192.168.220.20",
"DHCPScopeIpEnd":"192.168.220.254"
}

Просмотреть файл

@ -0,0 +1,28 @@
{
"DSCDataDrivenSQLServer":"DD-DSC",
"SQLServerBitsLocation": "\\\\DD-DC\\",
"SQLAdminAccount": "DD-LAB\\Administrator",
"WindowsBitsLocation": "\\\\DD-DC\\Windows2016ISO\\Sources\\sxs",
"OutputPath": "C:\\DSC_Mof",
"DefaultSQLConfigurationName": "SQLStandAloneNode",
"StandaloneParentConfigurationName":"SQLStandAlone",
"PSDscAllowDomainUser": "$true",
"PSDscAllowPlainTextPassword": "$true",
"SQLInstanceName": "MSSQLSERVER",
"SQLInstallShareDir": "C:\\Program Files\\Microsoft SQL Server",
"SQLUserDBDir": "C:\\Program Files\\Microsoft SQL Server",
"SQLTempDBLogDir": "C:\\Program Files\\Microsoft SQL Server",
"SQLTempDBDir": "C:\\Program Files\\Microsoft SQL Server",
"InstallSQLDataDir": "C:\\Program Files\\Microsoft SQL Server",
"SQLUserDBLogDir": "C:\\Program Files\\Microsoft SQL Server",
"InstallSharedWOWDir": "c:\\Program Files (x86)\\Microsoft SQL Server",
"Features": "SQLENGINE,IS",
"SQLBackupDir": "C:\\Program Files\\Microsoft SQL Server\\Backup",
"InstanceDir": "C:\\Program Files\\Microsoft SQL Server",
"DMaxDop": "$true",
"MaxDopVal": "0",
"DMemory": "$true",
"MinMemory": "256",
"MaxMemory": "512",
"NodetoConfigure": "$env:computername"
}

Просмотреть файл

@ -0,0 +1,22 @@
{
"ScriptLocation": "D:\\LabInaBox\\Scripts",
"DSCResourceDest": "C:\\Program Files\\WindowsPowerShell\\Modules",
"DSCResourceSource":"D:\\LabInaBox\\DSCResources",
"ParentFolderPath": "C:\\LabInaBox\\ParentVMDisks",
"ParentFolderPathSource":"D:\\LabInaBox\\ParentVMDisks",
"ChildFolderPath": "E:\\LabInaBox\\ChildVMDisks\\Demo",
"ISOFolderPath" : "D:\\LabInaBox\\ISO",
"DomainJoinPath": "E:\\LabInaBox\\ChildVMDisks\\Demo\\DomainJoin",
"DCMachineName": "DemoDC",
"DomainJoinServer": ["DemoDSC1","DemoSQL1","DemoSQL2"],
"localAdminPass": "P@ssw0rd",
"domainAdminPass": "P@ssw0rd",
"sysPrepDriveName": "Win16SysPrepFinal.vhdx",
"DCSysPrepDriveName": "Win16SysPrepFinal.vhdx",
"SwitchName": "GuestToGuest210",
"domainname": "DemoLab",
"domainExtention": ".com",
"DomainIpAddress":"192.168.210.1",
"DHCPScopeIpStart": "192.168.210.20",
"DHCPScopeIpEnd":"192.168.210.254"
}

Просмотреть файл

@ -0,0 +1,25 @@
{
"ScriptLocation": "D:\\LabInaBox\\Scripts",
"DSCResourceDest": "C:\\Program Files\\WindowsPowerShell\\Modules",
"DSCResourceSource":"D:\\LabInaBox\\DSCResources",
"ParentFolderPath": "C:\\LabInaBox\\ParentVMDisks",
"ParentFolderPathSource":"D:\\LabInaBox\\ParentVMDisks",
"ChildFolderPath": "E:\\LabInaBox\\ChildVMDisks\\FCI",
"ISOFolderPath" : "D:\\LabInaBox\\ISO",
"DomainJoinPath": "E:\\LabInaBox\\ChildVMDisks\\FCI\\DomainJoin",
"DCMachineName": "FCIDC",
"DeveloperMachine" : "FCIDev",
"ServertoQueue": ["FCISQL1","FCI-SQL2","FCI-SQL3","FCI-SQL4"],
"ServerConfig": "SQLStandAlone",
"DomainJoinServer": ["FCIDSC","FCISQL1","FCISQL2","FCISQL3","FCISQL4","FCIDev","FCISCSI"],
"localAdminPass": "P@ssw0rd",
"domainAdminPass": "P@ssw0rd",
"sysPrepDriveName": "Win16SysPrepFinal.vhdx",
"DCSysPrepDriveName": "Win16SysPrepFinal.vhdx",
"SwitchName": "GuestToGuest240",
"domainname": "FCILab",
"domainExtention": ".com",
"DomainIpAddress":"192.168.240.1",
"DHCPScopeIpStart": "192.168.240.20",
"DHCPScopeIpEnd":"192.168.240.254"
}

Просмотреть файл

@ -0,0 +1,24 @@
{
"ScriptLocation": "D:\\LabInaBox\\Scripts",
"DSCResourceDest": "C:\\Program Files\\WindowsPowerShell\\Modules",
"DSCResourceSource":"D:\\LabInaBox\\DSCResources",
"ParentFolderPath": "C:\\LabInaBox\\ParentVMDisks",
"ParentFolderPathSource":"D:\\LabInaBox\\ParentVMDisks",
"ChildFolderPath": "E:\\LabInaBox\\ChildVMDisks\\LD",
"ISOFolderPath" : "D:\\LabInaBox\\ISO",
"DomainJoinPath": "E:\\LabInaBox\\ChildVMDisks\\LD\\DomainJoin",
"DCMachineName": "LD-DC",
"DomainJoinServer": ["LD-WSQL1"],
"LinuxServer":["LD-LSQL1"],
"localAdminPass": "P@ssw0rd",
"domainAdminPass": "P@ssw0rd",
"LinuxParentDrive": "CentOSTemp3.vhdx",
"sysPrepDriveName": "Win16SysPrepFinal.vhdx",
"DCSysPrepDriveName": "Win16SysPrepFinal.vhdx",
"SwitchName": "GuestToGuest230",
"domainname": "LD-Lab",
"domainExtention": ".com",
"DomainIpAddress":"192.168.230.1",
"DHCPScopeIpStart": "192.168.230.20",
"DHCPScopeIpEnd":"192.168.230.254"
}

Просмотреть файл

@ -0,0 +1,30 @@
#Requires -RunAsAdministrator
$start = Get-Date
Write-Output -Message "Lab Creation began at: $start"
$Config = 'D:\LabInaBox\Examples\DD-Config.json'
$SQLConfig = 'D:\LabInaBox\Examples\DD-SQLConfig.json'
Import-Module -name D:\LabInaBox\modules\LabinaBox.psm1
New-LabinaBox -configuration $Config -Verbose
#CheckPoint-LabinaBox -configuration $DDConfig
New-DSCDataDrivenSQL -configuration $Config -SQLconfiguration $SQLConfig -Verbose
Add-ServerConfigtoQueue -configuration $Config -SQLconfiguration $SQLConfig -Verbose
#Update-LabinaBox -configuration $Config -Verbose
#Stop-LabinaBox -configuration $Config
#Start-LabinaBox -configuration $Config
#Remove-LabinaBoxSnapshot -configuration $Config
#Remove-LabinaBox -configuration $Config
$end = Get-Date
$diff = $end -$start
Write-Output -Message "Completed lab build @ $($end.ToLongTimeString())"
Write-Output -Message "Time to build lab: $("{0:N2}" -f ($diff.TotalMinutes)) minutes"
psedit D:\LabInaBox\Examples\DD-Config.json

Просмотреть файл

@ -0,0 +1,26 @@
#Requires -RunAsAdministrator
$start = Get-Date
Write-Output -Message "Lab Creation began at: $start"
$Config = 'D:\LabInaBox\Examples\DSC-Test.json'
$SQLConfig = 'D:\LabInaBox\Examples\DD-SQLConfig.json'
Import-Module -name D:\LabInaBox\modules\LabinaBox.psm1
New-LabinaBox -configuration $Config -Verbose
#CheckPoint-LabinaBox -configuration $DDConfig
#New-DSCDataDrivenSQL -configuration $DDConfig -SQLconfiguration $DDSQLConfig -Verbose
#Add-ServerConfigtoQueue -configuration $DDConfig -SQLconfiguration $DDSQLConfig -Verbose
Update-LabinaBox -configuration $Config -Verbose
#Stop-LabinaBox -configuration $Config
#Start-LabinaBox -configuration $Config
#Remove-LabinaBoxSnapshot -configuration $Config
#Remove-LabinaBox -configuration $Config
$end = Get-Date
$diff = $end -$start
Write-Output -Message "Completed lab build @ $($end.ToLongTimeString())"
Write-Output -Message "Time to build lab: $("{0:N2}" -f ($diff.TotalMinutes)) minutes"

Просмотреть файл

@ -0,0 +1,27 @@
#Requires -RunAsAdministrator
$start = Get-Date
Write-Output -Message "Lab Creation began at: $start"
$Config = 'D:\LabInaBox\Examples\DSC-Test.json'
Import-Module -name D:\LabInaBox\modules\LabinaBox.psm1
New-LabinaBox -configuration $Config -Verbose
CheckPoint-LabinaBox -configuration $Config
#New-DSCDataDrivenSQL -configuration $Config -SQLconfiguration $SQLConfig -Verbose
#Add-ServerConfigtoQueue -configuration $Config -SQLconfiguration $SQLConfig -Verbose
#Update-LabinaBox -configuration $Config -Verbose
#Stop-LabinaBox -configuration $Config
#Start-LabinaBox -configuration $Config
#Remove-LabinaBoxSnapshot -configuration $Config
#Remove-LabinaBox -configuration $Config
$end = Get-Date
$diff = $end -$start
Write-Output -Message "Completed lab build @ $($end.ToLongTimeString())"
Write-Output -Message "Time to build lab: $("{0:N2}" -f ($diff.TotalMinutes)) minutes"
psedit 'D:\LabInaBox\Examples\FCI-Config.json'

Просмотреть файл

@ -0,0 +1,50 @@
Add-AzureRmAccount
$AutoAccount = 'LIABAuto'
$AutoRG = 'LIAB_RG'
$cred = Get-Credential
# Define the parameters for Get-AzureRmAutomationDscOnboardingMetaconfig using PowerShell Splatting
$Params = @{
ResourceGroupName = 'LIAB_RG'; # The name of the ARM Resource Group that contains your Azure Automation Account
AutomationAccountName = 'LIABAuto'; # The name of the Azure Automation Account where you want a node on-boarded to
ComputerName = @('AAL-SQL2'); # The names of the computers that the meta configuration will be generated for
OutputFolder = "E:\";
}
# Use PowerShell splatting to pass parameters to the Azure Automation cmdlet being invoked
Get-AzureRmAutomationDscOnboardingMetaconfig @Params -Force
Set-DscLocalConfigurationManager -Path E:\DscMetaConfigs -Credential $cred
#Modifies the node configuration that a DSC node is mapped to.
$MyNode=Get-AzureRMAutomationDscNode -ResourceGroupName $AutoRG -AutomationAccountName $AutoAccount -Name 'AAL-SQL2'
Set-AzureRmAutomationDscNode -NodeConfigurationName 'TestConfig.WebServer' -ResourceGroupName $AutoRG -AutomationAccountName $AutoAccount -Id $MyNode.Id
#Remove Node from Azure Automation Control
Unregister-AzureRmAutomationDscNode -Id $MyNode.Id -ResourceGroupName $AutoRG -AutomationAccountName $AutoAccount -Force
#Registers Azure VM as a DSC Node
Register-AzureRMAutomationDscNode
#Get-AzureRmAutomationAccount -Name $AutoAccount -ResourceGroupName $AutoRG
New-AzureRMAutomationCredential -AutomationAccountName $AutoAccount -ResourceGroupName $AutoRG -Name 'AALAdministrator' -Description 'AAL Domain Administrator Account' -Value $cred
$myCredential = Get-AzureRMAutomationCredential -Name 'AALAdministrator2' -ResourceGroupName $AutoRG -AutomationAccountName $AutoAccount
$userName = $myCredential.UserName
$securePassword = $myCredential.Password
$password = $myCredential.GetNetworkCredential().Password
get-azurermvm | Stop-AzureRmVM
$cred
$myCredential.UserName
$myCredential = Get-AzureRMAutomationCredential -Name 'AALAdministrator2' -ResourceGroupName $AutoRG -AutomationAccountName $AutoAccount
$myCredential | gm
$myCredential

Просмотреть файл

@ -0,0 +1,47 @@

#################################################################################################################
#Availability Groups
#################################################################################################################
#Import the tools to convert Configuration to HashTable
Import-Module "C:\Program Files\WindowsPowerShell\Modules\DSC-data-driven-deployment\modules\ConfigurationHelper.psm1"
$RG = 'LIAB_RG'
$Auto = 'LIABAuto'
$Config = 'DefaultSQLOnPrem'
$ConfigParms = $(Get-Content 'D:\LabInaBox\LabConfig\AAL\AAL_SQLConfigAO.json')| ConvertFrom-Json| Convert-PSObjectToHashtable
$Params = @{
ResourceGroupName = $RG; # The name of the ARM Resource Group that contains your Azure Automation Account
AutomationAccountName = $Auto; # The name of the Azure Automation Account where you want a node on-boarded to
ComputerName = @('AAL-SQL4'); # The names of the computers that the meta configuration will be generated for
OutputFolder = "E:\";
}
# Use PowerShell splatting to pass parameters to the Azure Automation cmdlet being invoked
Get-AzureRmAutomationDscOnboardingMetaconfig @Params -Force
$cred =Get-Credential
Set-DscLocalConfigurationManager -Path E:\DscMetaConfigs -Credential $cred -Force
$ConfigurationData =@{
AllNodes = @(
@{
NodeName = "SQLServer"
PSDscAllowPlainTextPassword = $true
PSDscAllowDomainUser =$true
}
)
}
#Compile New Configuration
$CompilationJob = Start-AzureRmAutomationDscCompilationJob -ResourceGroupName $RG -AutomationAccountName $Auto -ConfigurationName 'DefaultAOOnPremPrimary' -Parameters $ConfigParms -ConfigurationData $ConfigurationData
$CompilationJob2 = Start-AzureRmAutomationDscCompilationJob -ResourceGroupName $RG -AutomationAccountName $Auto -ConfigurationName 'DefaultAOOnPremSecondary' -Parameters $ConfigParms -ConfigurationData $ConfigurationData
$NodeIdPrimary = Get-AzureRmAutomationDscNode -ResourceGroupName $RG -AutomationAccountName $Auto | Where-Object NAME -EQ 'AAL-SQL1' | Select-Object Id
$NodeIDSecondary = Get-AzureRmAutomationDscNode -ResourceGroupName $RG -AutomationAccountName $Auto | Where-Object NAME -EQ 'AAL-SQL2' | Select-Object Id
Set-AzureRmAutomationDscNode -NodeConfigurationName 'DefaultAOOnPremPrimary.SQLServer' -ResourceGroupName $RG -AutomationAccountName $Auto -Id $NodeIdPrimary.Id
Set-AzureRmAutomationDscNode -NodeConfigurationName 'DefaultAOOnPremSecondary.SQLServer' -ResourceGroupName $RG -AutomationAccountName $Auto -Id $NodeIDSecondary.Id

Просмотреть файл

@ -0,0 +1,90 @@
Configuration DefaultSQLOnPrem2
{
param(
[string] $WindowsBitsLocation,
[string] $SQLServerBitsLocation,
[string] $SQLInstanceName,
[string] $Features,
[string] $SQLAdminAccount,
[string] $SQLInstallSharedDir,
[string] $InstallSharedWowDir,
[string] $InstanceDir,
[string] $InstallSQLDataDir,
[string] $SQLUserDBDir,
[string] $SQLUserDBLogDir,
[string] $SQLTempDBDir,
[string] $SQLTempDBLogDir,
[string] $SQLBackupDir,
[string] $AzureCred
)
Import-DscResource -ModuleName xSQLServer -ModuleVersion 2.0.0.0
Import-DscResource -ModuleName PSDesiredStateConfiguration
$Admincreds = Get-AutomationPSCredential -Name $AzureCred
Node SQLServer
{
LocalConfigurationManager
{
AllowModuleOverwrite = $true
ConfigurationMode = 'ApplyAndAutoCorrect'
RebootNodeIfNeeded = $true
}
WindowsFeature "NET"
{
Ensure = "Present"
Name = "NET-Framework-Core"
Source = $WindowsBitsLocation
}
xSqlServerSetup SQL
{
SourcePath = $SQLServerBitsLocation
SetupCredential = $Admincreds
InstanceName = $SQLInstanceName
Features = $Features
SQLSysAdminAccounts = $SQLAdminAccount
InstallSharedDir = $SQLInstallSharedDir
InstallSharedWOWDir = $InstallSharedWowDir
InstanceDir = $InstanceDir
InstallSQLDataDir = $InstallSQLDataDir
SQLUserDBDir = $SQLUserDBDir
SQLUserDBLogDir = $SQLUserDBLogDir
SQLTempDBDir = $SQLTempDBDir
SQLTempDBLogDir = $SQLTempDBLogDir
SQLBackupDir = $SQLBackupDir
DependsOn = '[WindowsFeature]NET'
}
xSqlServerFirewall ($Node.NodeName)
{
SourcePath = $SQLServerBitsLocation
InstanceName = $SQLInstanceName
Features = $Features
DependsOn = "[xSqlServerSetup]SQL"
}
xSQLServerPowerPlan ($Node.Nodename)
{
Ensure = "Present"
}
xSQLServerMemory ($Node.Nodename)
{
Ensure = "Present"
DynamicAlloc = $True
SQLInstanceName = $SQLInstanceName
DependsOn = "[xSqlServerSetup]SQL"
}
xSQLServerMaxDop($Node.Nodename)
{
Ensure = "Present"
DynamicAlloc = $true
SQLInstanceName = $SQLInstanceName
DependsOn = "[xSqlServerSetup]SQL"
}
}
}