Welcome › Forums › General PowerShell Q&A › Downlaod file.exe from internet.
- This topic has 4 replies, 2 voices, and was last updated 9 months, 2 weeks ago by
Participant.
-
AuthorPosts
-
-
April 15, 2020 at 1:39 pm #218958
Hi all, I’m new in PowerShell. I’m trying to create a script where I download an exe file.
I found some example from internet and I wrote it, but when I execute my script I receive the following error:
Invoke-WebRequest : Could not find a part of the path ‘C:\Users\xxxxxx\Downloads\SW\Download\’.
At line:1 char:1
+ Invoke-WebRequest -Uri $url -OutFile $output
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-WebRequest], DirectoryNotFoundException
+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.InvokeWebRequestCommandCould you help me please to understand the error?
-
April 15, 2020 at 1:46 pm #218970
Antonella, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.
When you post code or error messages or sample data or console output format it as code using the code tags “PRE“, please. Thanks in advance.
It looks like you did not specify a file not just a directory for your parameter -OutFile.
-
April 15, 2020 at 1:55 pm #218973
Thanks,
I haven’t wrote all the script… I write it:
PowerShell123$output = "C:\Users\xxxxxxx\Downloads\SW\Download\"$url = "https://www.google.com/chrome/"Invoke-WebRequest -Uri $url -OutFile $outputThe output I received
PowerShell123456Invoke-WebRequest : Could not find a part of the path ‘C:\Users\xxxxxx\Downloads\SW\Download\’.At line:1 char:1+ Invoke-WebRequest -Uri $url -OutFile $output+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:) [Invoke-WebRequest], DirectoryNotFoundException+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand -
April 15, 2020 at 1:58 pm #218976
$output = “C:\Users\xxxxxxx\Downloads\SW\Download\”
I assume it is a setup file you try to download. You should use something like this:
PowerShell1$output = "C:\Users\xxxxxxx\Downloads\SW\Download\setup.exe"It should be a complete path including the file name.
-
April 15, 2020 at 2:03 pm #218985
Oh Thanks a lot.
It works! I thought I haven’t to write the exe file name.
Thanks a lot again.
-
-
AuthorPosts
- The topic ‘Downlaod file.exe from internet.’ is closed to new replies.