I am using Windows 7. It has powershell Version 2 installed in it. But the version has some bug with split path. So I went with the System.IO.Path for a powershell downloading and executing script. But it is still showing error.
This is the error what I am getting :
+ @('https://cdn.bringatrailer.com/wp-content/uploads/2018/01/GTX-Low-Res-4-940
x627.jpg','https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/2019_Ford_
Mustang_GT_5.0_facelift.jpg/1200px-2019_Ford_Mustang_GT_5.0_facelift.jpg') |for
each{$fileName = $env:TEMP + ([System.IO.Path]::GetFileName($Path) );(New-Objec
t System.Net.WebClient).DownloadFile <<<< ($_,$fileName);Invoke-Item $fileName}
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Exception calling "DownloadFile" with "2" argument(s): "An exception occurred d
uring a WebClient request."
At line:1 char:351
+ @('https://cdn.bringatrailer.com/wp-content/uploads/2018/01/GTX-Low-Res-4-940
x627.jpg','https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/2019_Ford_
Mustang_GT_5.0_facelift.jpg/1200px-2019_Ford_Mustang_GT_5.0_facelift.jpg') |for
each{$fileName = $env:TEMP + ([System.IO.Path]::GetFileName($Path) );(New-Objec
t System.Net.WebClient).DownloadFile <<<< ($_,$fileName);Invoke-Item $fileName}
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Here is my code that i tried to run :
@echo off
powershell "@('https://cdn.bringatrailer.com/wp-content/uploads/2018/01/GTX-Low-Res-4-940x627.jpg','https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/2019_Ford_Mustang_GT_5.0_facelift.jpg/1200px-2019_Ford_Mustang_GT_5.0_facelift.jpg') |foreach{$fileName = $env:TEMP + ([System.IO.Path]::GetFileName($Path) );(New-Object System.Net.WebClient).DownloadFile($_,$fileName);Invoke-Item $fileName}"