Skip to content

standardbeagle/Invoke-Download

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Invoke-Download

A high-performance PowerShell cmdlet for downloading files with advanced features including multi-protocol support, parallel downloads, retry logic, throttling, and more.

Features

  • Multi-Protocol Support: HTTP, HTTPS, HTTP/3, FTP, and SCP
  • HTTP/3 Support: Leverage the latest HTTP protocol for improved performance (requires .NET 6+ and Windows 11/Server 2022+)
  • Parallel Downloads: Download multiple files concurrently with configurable concurrency limits
  • Automatic Retry: Exponential backoff retry logic for failed downloads
  • Bandwidth Throttling: Control download speed to manage network usage
  • Resume Capability: Resume interrupted downloads (HTTP/HTTPS only)
  • Checksum Validation: Verify file integrity with MD5, SHA1, SHA256, or SHA512
  • Progress Tracking: Real-time progress updates with download speed
  • Authentication Support: PSCredential support for FTP, SCP, and HTTP Basic Auth
  • Custom Headers: Add custom HTTP headers for advanced scenarios
  • Pipeline Support: Process URIs from pipeline input

Installation

Option 1: Import from Local Path

# Import the module for current session
Import-Module "C:\Users\andyb\work\dl-invoke\Invoke-Download.psd1"

# Add to your PowerShell profile for automatic loading
Add-Content $PROFILE "`nImport-Module 'C:\Users\andyb\work\dl-invoke\Invoke-Download.psd1'"

Option 2: Install to PowerShell Modules Directory

# Copy module to user modules directory
$modulePath = "$env:USERPROFILE\Documents\PowerShell\Modules\Invoke-Download"
New-Item -Path $modulePath -ItemType Directory -Force
Copy-Item "C:\Users\andyb\work\dl-invoke\*" -Destination $modulePath -Recurse

# Import the module
Import-Module Invoke-Download

Option 3: System-wide Installation (Requires Admin)

# Copy to system modules directory (requires admin)
$modulePath = "$env:ProgramFiles\PowerShell\Modules\Invoke-Download"
New-Item -Path $modulePath -ItemType Directory -Force
Copy-Item "C:\Users\andyb\work\dl-invoke\*" -Destination $modulePath -Recurse

Requirements

  • PowerShell 5.1 or higher (PowerShell 7+ recommended for HTTP/3 support)
  • Windows 11 or Windows Server 2022+ for HTTP/3 support
  • .NET 6 or higher for HTTP/3 support
  • Posh-SSH module for SCP support (optional): Install-Module -Name Posh-SSH

Usage Examples

Basic Download

# Download a single file
Invoke-Download -Uri "https://example.com/file.zip" -Destination "C:\Downloads\file.zip"

Download with Throttling

# Limit bandwidth to 1MB/s
Invoke-Download -Uri "https://example.com/largefile.iso" `
                -Destination "C:\Downloads\" `
                -ThrottleLimit 1MB

Resume Interrupted Download

# Resume a partially downloaded file
Invoke-Download -Uri "https://example.com/largefile.iso" `
                -Destination "C:\Downloads\largefile.iso" `
                -Resume

Multiple Files with Parallel Downloads

# Download multiple files concurrently
$urls = @(
    "https://example.com/file1.zip",
    "https://example.com/file2.zip",
    "https://example.com/file3.zip"
)

Invoke-Download -Uri $urls `
                -Destination "C:\Downloads\" `
                -MaxConcurrent 3 `
                -MaxRetries 5

FTP with Authentication

# Download from FTP server
$cred = Get-Credential
Invoke-Download -Uri "ftp://ftp.example.com/file.txt" `
                -Destination "C:\Downloads\" `
                -Credential $cred

Checksum Validation

# Download and verify file integrity
Invoke-Download -Uri "https://example.com/file.zip" `
                -Destination "C:\Downloads\file.zip" `
                -Checksum "a3f5c2d17b8e4a9c8f1d2e4a6b8c9d0f..." `
                -ChecksumAlgorithm SHA256

HTTP/3 with Custom Headers

# Use HTTP/3 with authorization header
Invoke-Download -Uri "https://api.example.com/download/file.zip" `
                -Destination "C:\Downloads\" `
                -UseHttp3 `
                -Headers @{
                    "Authorization" = "Bearer your-token-here"
                    "X-Custom-Header" = "value"
                }

SCP Download

# Download via SCP (requires Posh-SSH module)
$cred = Get-Credential
Invoke-Download -Uri "scp://user@server.com/path/to/file.txt" `
                -Destination "C:\Downloads\" `
                -Credential $cred

Pipeline Support

# Process URLs from pipeline
Get-Content "urls.txt" | Invoke-Download -Destination "C:\Downloads\"

# Or with custom objects
@(
    @{Uri="https://example.com/file1.zip"; Name="file1.zip"},
    @{Uri="https://example.com/file2.zip"; Name="file2.zip"}
) | ForEach-Object {
    Invoke-Download -Uri $_.Uri -Destination "C:\Downloads\$($_.Name)"
}

Advanced Configuration

# Full configuration example
Invoke-Download -Uri "https://example.com/file.zip" `
                -Destination "C:\Downloads\file.zip" `
                -MaxRetries 5 `
                -RetryDelay 3 `
                -ThrottleLimit 2MB `
                -Timeout 600 `
                -Resume `
                -Checksum "abc123..." `
                -ChecksumAlgorithm SHA256 `
                -UserAgent "MyApp/1.0" `
                -Headers @{"X-API-Key"="secret"} `
                -Force `
                -Verbose

Parameters

Core Parameters

  • -Uri (Required): URL(s) to download. Supports HTTP, HTTPS, FTP, and SCP protocols
  • -Destination (Required): Output path for downloaded file(s)

Retry & Reliability

  • -MaxRetries: Maximum retry attempts (default: 3)
  • -RetryDelay: Initial delay between retries in seconds (default: 2)
  • -Resume: Resume partial downloads if supported by server

Performance

  • -ThrottleLimit: Maximum bandwidth in bytes/second (0 = unlimited)
  • -MaxConcurrent: Maximum concurrent downloads for multiple files (default: 4)
  • -Timeout: Timeout in seconds for each attempt (default: 300)

Security

  • -Checksum: Expected checksum value for validation
  • -ChecksumAlgorithm: Algorithm for checksum (MD5, SHA1, SHA256, SHA512)
  • -Credential: PSCredential for authenticated downloads

HTTP-Specific

  • -UserAgent: Custom User-Agent string
  • -Headers: Hashtable of custom HTTP headers
  • -UseHttp3: Attempt HTTP/3 protocol (requires .NET 6+ and Windows 11+)

Behavior

  • -Force: Overwrite existing files without prompting
  • -Quiet: Suppress progress output

Performance Tips

  1. Enable HTTP/3 for modern servers: -UseHttp3
  2. Use parallel downloads for multiple files: -MaxConcurrent 4
  3. Adjust buffer sizes by modifying the module (default: 8KB)
  4. Resume downloads on unstable connections: -Resume
  5. Throttle bandwidth to prevent network saturation: -ThrottleLimit 5MB

Protocol Support Details

HTTP/HTTPS

  • Full support for HTTP/1.1, HTTP/2, and HTTP/3
  • Resume capability with Range headers
  • Custom headers and authentication
  • Automatic decompression

FTP

  • Binary mode transfers
  • Authentication support
  • Progress tracking

SCP

  • Requires Posh-SSH module
  • SSH key and password authentication
  • Custom port support

Troubleshooting

HTTP/3 Not Working

# Verify .NET version (requires 6.0+)
dotnet --version

# Check PowerShell version (requires 7.0+)
$PSVersionTable.PSVersion

SCP Module Missing

# Install Posh-SSH module
Install-Module -Name Posh-SSH -Scope CurrentUser

Resume Not Working

Ensure the server supports Range requests. Test with:

(Invoke-WebRequest -Uri "https://example.com/file.zip" -Method Head).Headers.'Accept-Ranges'

Version History

1.0.0 (2025-12-24)

  • Initial release
  • Multi-protocol support (HTTP, HTTPS, HTTP/3, FTP, SCP)
  • Parallel downloads with concurrency control
  • Automatic retry with exponential backoff
  • Bandwidth throttling
  • Resume capability
  • Checksum validation
  • Comprehensive progress tracking

License

Copyright (c) 2025. All rights reserved.

Contributing

Contributions are welcome! Please submit issues and pull requests on GitHub.

Support

For issues, questions, or feature requests, please open an issue on GitHub.

About

High-performance PowerShell cmdlet for downloading files with multi-protocol support (HTTP/HTTPS/FTP/SCP), parallel downloads, retry logic, throttling, and resume capability

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors