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
/
Provision-PullClient.ps1
66 lines (52 loc) · 2.35 KB
/
Provision-PullClient.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
<#
.SYNOPSIS
Configures a machine to be a pull client in a DSC environment
.DESCRIPTION
Takes the parameters of a configuration GUID and pull server address, determines which version of PowerShell is installed and applies the relevant configuration to act as a pull server client.
.PARAMETER ConfigurationIDGUID
The GUID of the configuration that the client will apply.
.PARAMETER PullServerURL
The full URL of the pull server that will be used by the client
.EXAMPLE
Provision client to look at pullserver.example.com and use a configuration GUID
ProvisionPullClient.ps1 -ConfigurationIDGUID e7d38156-02b2-42d3-ad0a-4457fe8cf380 -PullServerURL https://pullserver.example.com:8080/PSDSCPullServer.svc -CertThumb $CertThumb
#>
[cmdletbinding()]
Param
(
[String]$ConfigurationIDGUID,
[Parameter(Mandatory=$True)]
[String]$ConfigurationNames,
[Parameter(Mandatory=$True)]
[String]$PullServerURL,
[Parameter(Mandatory=$True)]
[String]$PullServerRegKey,
[String]$ThumbPrint
)
# Temp folder used for outputting the MOF files so they are in a known location
If (!(Test-Path -Path "$PSScriptRoot\DSC"))
{
New-Item -Path "$PSScriptRoot\DSC" -ItemType Directory
}
# Use switch to configure the pull client dependant on version of PS installed
# PS v5 https://msdn.microsoft.com/en-us/powershell/dsc/pullclientconfigid
# PS v4 https://msdn.microsoft.com/en-us/powershell/dsc/pullclientconfigid4
Switch ($PSVersionTable.PSVersion.Major)
{
5
{
#$ConfigurationNames = ($ConfigurationNames.Split(',')).Trim()
Invoke-WebRequest https://raw.githubusercontent.com/justeat/PowerShellDSCUtils/master/Version5DSC.ps1 -OutFile "$PSScriptRoot\DSC\Version5DSC.ps1"
. $PSScriptRoot\DSC\Version5DSC.ps1 -ConfigurationNames $ConfigurationNames -PullServerUrl $PullServerURL -PullServerRegKey $PullServerRegKey -Verbose | Tee-Object -FilePath "$PSScriptRoot\DSC\Version5DSC.log"
} # PoSh 5
4
{
Invoke-WebRequest https://raw.githubusercontent.com/justeat/PowerShellDSCUtils/master/Version4DSC.ps1 -OutFile "$PSScriptRoot\DSC\Version4DSC.ps1"
. $PSScriptRoot\DSC\Version4DSC.ps1 -ConfigurationIDGUID $ConfigurationIDGUID -PullServerUrl $PullServerURL -ThumbPrint $ThumbPrint
} # PoSh 4
# Graceful exit if PS Version doesnt mach above
default
{
exit
} # default
}