forked from dsccommunity/xPSDesiredStateConfiguration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xRemoteFile_DownloadFileUsingProxyConfig.ps1
117 lines (96 loc) · 3.7 KB
/
xRemoteFile_DownloadFileUsingProxyConfig.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<#PSScriptInfo
.VERSION 1.0.1
.GUID f57b22a3-b2bd-4fb5-9fa0-3997055d4577
.AUTHOR Microsoft Corporation
.COMPANYNAME Microsoft Corporation
.COPYRIGHT
.TAGS DSCConfiguration
.LICENSEURI https://github.com/dsccommunity/xPSDesiredStateConfiguration/blob/main/LICENSE
.PROJECTURI https://github.com/dsccommunity/xPSDesiredStateConfiguration
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES First version.
.PRIVATEDATA 2016-Datacenter,2016-Datacenter-Server-Core
#>
#Requires -module 'xPSDesiredStateConfiguration'
<#
.SYNOPSIS
Configuration that downloads a file using proxy.
.DESCRIPTION
Configuration that downloads a file using proxy.
.PARAMETER NodeName
The names of one or more nodes to compile a configuration for.
Defaults to 'localhost'.
.PARAMETER DestinationPath
The path where the remote file should be downloaded
.PARAMETER Uri
The URI of the file which should be downloaded. It must be a HTTP, HTTPS
or FILE resource.
.PARAMETER UserAgent
The user agent string for the web request.
.PARAMETER Headers
The headers of the web request.
.PARAMETER Proxy
The proxy server for the request, rather than connecting directly to the
Internet resource. Should be the URI of a network proxy server (e.g
'http://10.20.30.1').
.EXAMPLE
xRemoteFile_DownloadFileUsingProxyConfig -DestinationPath "$env:SystemDrive\fileName.jpg" -Uri 'http://www.contoso.com/image.jpg' -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Headers @{'Accept-Language' = 'en-US'} -Proxy 'http://10.22.93.1'
Compiles a configuration that downloads the file 'http://www.contoso.com/image.jpg',
using proxy 'http://10.22.93.1', to the local file "$env:SystemDrive\fileName.jpg".
.EXAMPLE
$configurationParameters = @{
DestinationPath = "$env:SystemDrive\fileName.jpg"
Uri = 'http://www.contoso.com/image.jpg'
UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer
Headers = @{
'Accept-Language' = 'en-US'
}
Proxy = 'http://10.22.93.1'
}
Start-AzureRmAutomationDscCompilationJob -ResourceGroupName '<resource-group>' -AutomationAccountName '<automation-account>' -ConfigurationName 'xRemoteFile_DownloadFileUsingProxyConfig' -Parameters $configurationParameters
Compiles a configuration in Azure Automation that downloads the file
'http://www.contoso.com/image.jpg', using proxy 'http://10.22.93.1', to
the local file "$env:SystemDrive\fileName.jpg".
Replace the <resource-group> and <automation-account> with correct values.
#>
configuration xRemoteFile_DownloadFileUsingProxyConfig
{
param
(
[Parameter()]
[System.String[]]
$NodeName = 'localhost',
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]
$DestinationPath,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.String]
$Uri,
[Parameter()]
[System.String]
$UserAgent,
[Parameter()]
[System.Collections.Hashtable]
$Headers,
[Parameter(Mandatory = $true)]
[System.String]
$Proxy
)
Import-DscResource -ModuleName 'xPSDesiredStateConfiguration'
Node $nodeName
{
xRemoteFile 'DownloadFileUsingProxy'
{
DestinationPath = $DestinationPath
Uri = $Uri
UserAgent = $UserAgent
Headers = $Headers
Proxy = $Proxy
}
}
}