0

I have a Excel sheet with about 600 rows with each row containing hyperlink to some downloadable file.

    #rowMax is the maxinum rows in the excel sheet
$rowMax = 99
$StartingColumnValue = 3
$StartingRowValue = 2
for ($StartingRowValue; $StartingRowValue -lt $rowMax+1; $StartingRowValue++){
    write-host $ExcelWorkSheet.Cells.Item($StartingRowValue,$StartingColumnValue).Text
}

So far I've managed to display the names of the hyperlinks, but I would like to actually "click" on them and download them.

How may I accomplish this? Thanks.

1 Answers1

1

When you say you got the "name", I assume you got the link too.

Provided that it is the case, you could loop through the link and download them using the web client.

Here is a small example, extracting the filename from the URL (depending on the URL format, you might need to use another logic)

$WC = New-Object System.Net.WebClient 
$url = 'http://ec.ccm2.net/www.commentcamarche.net/download/files/SFDLC_v2.0_bin.zip'
$Filename = ($url.Split('/') | Select -Last 1)     

$wc.DownloadFile($url,"C:\__TMP\$Filename")

For alternative methods, take a look at this article.

If your file might be big and want some async method with progress, take a look at this gist

Sage Pourpre
  • 9,932
  • 3
  • 27
  • 39