הורד קבצים במסוף PowerShell

exprexs

Member
התסריט הבא מוריד קבצים.
יש לרשום קישור ישיר לקובץ הרצוי, וכן שם כלשהו לרבות הסיומת הנכונה של הקובץ ( zip, exe וכיוב' ).


קוד:
# Invoke-Webrequest "SomeName"
$FileName = ""
$Uri = ""
$OutputPath = Join-Path "~/Downloads" -ChildPath $FileName
$ProgressPreference = '0' 
Write-Host "Downloading $FileName"
$Action = IWR -Uri $Uri -OutFile $OutputPath
GCI $OutputPath
כך, בריבוי הורדות


קוד:
# Invoke-Webrequest "Multi-link"
$Combos = @(
    @{
        FileName = "SomeName1"
        Uri = "https://...1"
    }
    @{
        FileName = "SomeName2"
        Uri = "https://...2"
    }
    @{
        FileName = "SomeName3"
        Uri = "https://...3"
    }
)
foreach ($Combo in $Combos) {
    $FileName = $Combo.FileName
    $Uri = $Combo.Uri
    $OutputPath = Join-Path "~/Downloads" -ChildPath $FileName
    $ProgressPreference = '0'
    Write-Host "Downloading $FileName"
    $Action = IWR -Uri $Uri -OutFile $OutputPath
    GCI $OutputPath
}
#
 
נערך לאחרונה ב:

exprexs

Member
התסריטים הבאים, נסבים על פקודת Start-BitsTransfer.

קוד:
# Start-BitsTransfer
$FileName = "SomeName1"
$Uri = "https://....1"
$OutputPath = Join-Path "~\Downloads" -ChildPath $FileName
$ProgressPreference = '2'     # Continue
Write-Host "Downloading $FileName" -ForegroundColor Yellow -BackgroundColor Black
$Action = Start-BitsTransfer -Source $Uri -Destination $OutputPath -DisplayName $FileName -TransferType 'Download'
GCI $OutputPath
#

קוד:
# Start-BitsTransfer
$Combos = @(
    @{
        FileName = "SomeName1"
        Uri = "https://...1"
    }
    @{
        FileName = "SomeName2"
        Uri = "https://...2"
    }
    @{
        FileName = "SomeName3"
        Uri = "https://...3"
    }
)
foreach ($Combo in $Combos) {
    $FileName = $Combo.FileName
    $Uri = $Combo.Uri
    $OutputPath = Join-Path "~/Downloads" -ChildPath $FileName
    $ProgressPreference = '2'
    Write-Host "Downloading $FileName"
    $Action = Start-BitsTransfer -Source $Uri -Destination $OutputPath -DisplayName $FileName -TransferType 'Download'
    GCI $OutputPath
}
#
 
נערך לאחרונה ב:
למעלה