-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRootConfiguration.ps1
77 lines (64 loc) · 3.34 KB
/
RootConfiguration.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
$pref = $VerbosePreference
$VerbosePreference = 'continue'
$outputPath = "C:\LocalDepot\Output"
$ModuleList = @("PSDscResources", "xPSDesiredStateConfiguration", "WebAdministration", "xWebAdministration", "xNetworking", "xCertificate", "OctopusDSC", "xSmbShare", "xStorage", "xTimeZone", "xSystemVirtualMemory", "xPendingReboot", "SecurityPolicyDsc", "cSystemSecurity", "xComputerManagement")
Configuration RootConfiguration
{
# Get all ps1 files except this one
$configsToProcess = Get-ChildItem -Path "$($PSScriptRoot)\EnvData\Production" -Filter '*.ps1'
# PowerShell Automation cert for variable decryption.
# This should be the same thumbprint for the cert that is used in Encrypt-Password.ps1
$SecretCert = (Get-ChildItem Cert:\LocalMachine\My).where{$_.Thumbprint -eq "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
Import-DscResource -ModuleName PSDscResources -ModuleVersion 2.8.0.0
Import-DscResource -ModuleName xPSDesiredStateConfiguration -ModuleVersion 6.4.0.0
Import-DscResource -ModuleName WebAdministration -ModuleVersion 1.0.0.0
Import-DscResource -ModuleName xWebAdministration -ModuleVersion 1.18.0.0
Import-DscResource -ModuleName xSmbShare -ModuleVersion 2.0.0.0
Import-DscResource -ModuleName xCertificate -ModuleVersion 3.0.0.1
Import-DscResource -ModuleName xNetworking -ModuleVersion 5.0.0.0
Import-DscResource -ModuleName xStorage -ModuleVersion 3.2.0.0
Import-DscResource -ModuleName xTimeZone -ModuleVersion 1.6.0.0
Import-DscResource -ModuleName xSystemVirtualMemory -ModuleVersion 1.0.0
Import-DscResource -ModuleName xPendingReboot -ModuleVersion 0.3.0.0
Import-DscResource -ModuleName SecurityPolicyDsc -ModuleVersion 1.4.0.1
Import-DscResource -ModuleName cSystemSecurity -ModuleVersion 1.2.0.0
Import-DscResource -ModuleName xComputerManagement -ModuleVersion 2.0.0.0
# Start going over each node
Node $AllNodes.NodeName
{
# Import variables
. .\Functions\Variables.ps1
Write-Host "Processing configuration for $($Node.NodeName)..." -foregroundcolor Yellow
foreach ($config in $configsToProcess)
{
Write-Verbose "Processing sub-configuration $($config.BaseName)..."
. "$($config.FullName)" # Import script
. "$($config.BaseName)" -Node $Node # Invoke configuration
Write-Verbose "Finished processing sub-configuration $($config.BaseName)."
}
Write-Host "Finished Processing configuration for $($Node.NodeName)..." -foregroundcolor Yellow
}
}
If (!(test-path $outputPath))
{
New-Item -ItemType Directory -Force -Path $outputPath
}
$list = get-childitem C:\LocalDepot\ConfigData -file -recurse | Sort-Object name
$menu = @{}
for ($i = 1; $i -le $list.count; $i++)
{
Write-Host "$i. $($list[$i-1].basename)"
$menu.Add($i, ($list[$i - 1]))
#counts the number of items in list (this is used for the do until statement)
$number = $menu.Count
}
do
{
[int]$ans = Read-Host 'Enter selection'
}
until ($ans -le $number)
$selection = $menu.Item($ans)
$MergedDscConfig = Merge-DscConfigData -BaseConfigFilePath "C:\LocalDepot\Common_ConfigData.psd1" -OverrideConfigFilePath $selection.FullName
RootConfiguration -ConfigurationData $MergedDscConfig -OutputPath $outputPath
Publish-DSCModuleAndMof -Source $outputPath -ModuleNameList $ModuleList
$VerbosePreference = $pref