-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathInvoke-IcmpDownload.ps1
executable file
·35 lines (34 loc) · 1.03 KB
/
Invoke-IcmpDownload.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
function Invoke-IcmpDownload
{
[CmdletBinding()] Param(
[Parameter(Position = 0, Mandatory = $true)]
[String]
$IPAddress,
[Parameter(Position = 1, Mandatory = $true)]
[String]
$output
)
$ICMPClient = New-Object System.Net.NetworkInformation.Ping
$PingOptions = New-Object System.Net.NetworkInformation.PingOptions
$PingOptions.DontFragment = $True
echo "Downloading file, please wait..."
while ($true)
{
$sendbytes = ([text.encoding]::ASCII).GetBytes('')
$reply = $ICMPClient.Send($IPAddress, 1000, $sendbytes, $PingOptions)
if ($reply.Buffer)
{
$response = ([text.encoding]::ASCII).GetString($reply.Buffer)
if ($response -eq "done")
{
echo "File transfer complete; EXITING."
break;
}
else
{
$bytes = $reply.Buffer
add-content -value $bytes -encoding byte -path $output
}
}
}
}