forked from justeat/PowerShellDSCUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProvisionPullClient.ps1
More file actions
55 lines (43 loc) · 2.05 KB
/
Copy pathProvisionPullClient.ps1
File metadata and controls
55 lines (43 loc) · 2.05 KB
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
<#
.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 e7d38156-02b2-42d3-ad0a-4457fe8cf380 https://pullserver.example.com:8080/PSDSCPullServer.svc
#>
[cmdletbinding()]
Param (
# Parameter that defines the configuration ID to be used by the client
[Parameter(Mandatory=$True)]
[string]$ConfigurationIDGUID,
# Parameter that defines the Pull server the client will use
[Parameter(Mandatory=$True)]
[string]$PullServerURL
)
# Temp folder used for outputting the MOF files so they are in a known location
If (!(Test-Path "$PSScriptRoot\DSC"))
{
New-Item "$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 {
Invoke-WebRequest https://raw.githubusercontent.com/justeat/PowerShellDSCUtils/master/Version5DSC.ps1 -OutFile "$PSScriptRoot\DSC\Version5DSC.ps1"
. $PSScriptRoot\DSC\Version5DSC.ps1 -ConfigurationIDGUID $ConfigurationIDGUID -PullServerUrl $PullServerURL
}
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
}
# Graceful exit if PS Version doesnt mach above
default { exit }
}