forked from dsccommunity/xPSDesiredStateConfiguration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xRemoteFile_DownloadFileConfig.ps1
106 lines (87 loc) · 3.19 KB
/
xRemoteFile_DownloadFileConfig.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
<#PSScriptInfo
.VERSION 1.0.1
.GUID bf0cf053-65d3-4d1c-a1ca-762dd2b67f9b
.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.
.DESCRIPTION
Configuration that downloads a file.
.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.
.EXAMPLE
xRemoteFile_DownloadFileConfig -DestinationPath "$env:SystemDrive\fileName.jpg" -Uri 'http://www.contoso.com/image.jpg' -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Headers @{'Accept-Language' = 'en-US'}
Compiles a configuration that downloads the file 'http://www.contoso.com/image.jpg'
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'
}
}
Start-AzureRmAutomationDscCompilationJob -ResourceGroupName '<resource-group>' -AutomationAccountName '<automation-account>' -ConfigurationName 'xRemoteFile_DownloadFileConfig' -Parameters $configurationParameters
Compiles a configuration in Azure Automation that downloads the file
'http://www.contoso.com/image.jpg' to the local file
"$env:SystemDrive\fileName.jpg".
Replace the <resource-group> and <automation-account> with correct values.
#>
configuration xRemoteFile_DownloadFileConfig
{
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
)
Import-DscResource -ModuleName 'xPSDesiredStateConfiguration'
Node $nodeName
{
xRemoteFile 'DownloadFile'
{
DestinationPath = $DestinationPath
Uri = $Uri
UserAgent = $UserAgent
Headers = $Headers
}
}
}