This repository has been archived by the owner on Jul 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Version4DSC.ps1
74 lines (64 loc) · 2.38 KB
/
Version4DSC.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
[cmdletbinding(SupportsShouldProcess=$True)]
Param
(
[Parameter(Mandatory=$True)]
[string]$ConfigurationIDGUID,
[Parameter(Mandatory=$True)]
[string]$PullServerURL,
[Parameter(Mandatory=$True)]
[string]$ThumbPrint
) # Params
Set-Location "$PSScriptRoot"
Write-Verbose 'Constructing SetupLCM DSC Configuration object...'
Configuration SetupLCM
{
LocalConfigurationManager { AllowModuleOverwrite = $True
CertificateID = "$ThumbPrint"
ConfigurationID = "$ConfigurationIDGUID"
ConfigurationMode = 'ApplyAndAutoCorrect'
ConfigurationModeFrequencyMins = 30
DownloadManagerCustomData = @{
ServerUrl = "$PullServerURL"
}
DownloadManagerName = 'WebDownloadManager' RefreshFrequencyMins = 30 RefreshMode = 'PULL' RebootNodeIfNeeded = $True } # LCM
} # Configuration SetupLCM
Write-Verbose 'DONE!'
Write-Verbose ''
Write-Verbose 'Executing SetupLCM DSC Configuration object...'
if ($PSCmdlet.ShouldProcess('SetupLCM DSC Configuration', 'Executing'))
{
try
{
SetupLCM
} # try
catch
{
Write-Host -ForegroundColor Red "`tFailed to execute SetupLCM DSC Configuration!"
Write-Host -ForegroundColor Red "`tError details: $($Error[0].Exception)"
Write-Host -ForegroundColor Red "`tABORTING!"
break
} # catch
} # if
Write-Verbose 'DONE!'
Write-Verbose ''
Write-Verbose 'Applying SetupLCM DSC Configuration to self...'
if ($PSCmdlet.ShouldProcess('SetupLCM DSC Configuration', 'Applying'))
{
try
{
Set-DSCLocalConfigurationManager –Path .\SetupLCM –Verbose -ErrorAction Stop
} # try
catch
{
Write-Host -ForegroundColor Red "`tFailed to apply SetupLCM DSC Configuration to self!"
Write-Host -ForegroundColor Red "`tError details: $($Error[0].Exception)"
Write-Host -ForegroundColor Red "`tABORTING!"
break
} # catch
} # if
Write-Verbose 'DONE!'