-
Notifications
You must be signed in to change notification settings - Fork 1
/
Get-URIFile.psm1
60 lines (55 loc) · 1.59 KB
/
Get-URIFile.psm1
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
function Get-URIFile
{
<#
.Synopsis
Downloads a file or files from the specified URIs.
.DESCRIPTION
Downloads a file or files from the specified URIs and can make use of HTTP,
HTTPS, and FTP requests. A lesser Invoke-WebRequest for PowerShell 2.0.
.EXAMPLE
Get-URIFile -Uri "http://fqdn.local/path/to/object.exe"
The above example will download the file object.exe to the current dirrectory.
.EXAMPLE
C:\PS>Get-URIFile -Uri "http://fqdn.local/path/to/object.exe" -Destination "C:\temp 1"
The above example will download the file object.exe to the C:\temp 1 directory.
.INPUTS
System.Object
.OUTPUTS
None that should be used.
.NOTES
Currently the cmdlet will not signify if the download has completed at all.
.COMPONENT
This cmdlet makes use of the .NET class WebClient.
#>
[CmdletBinding()]
[OutputType()]
Param
(
# The location of the file to download.
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[String[]]
$Uri = @(),
# The downloaded file's distination.
[Parameter(Mandatory=$false,
Position=1)]
[String]
$Destination = $pwd
)
Begin
{
}
Process
{
for($i=0;$i -lt $Uri.Length; $i++)
{
$web = New-Object System.Net.WebClient
$web.DownloadFile($Uri[$i], "$Destination\$($Uri[$i].Substring($Uri[$i].LastIndexOf('/') + 1))")
$web.Dispose()
}
}
End
{
}
}