Downlaod file.exe from internet.

Welcome Forums General PowerShell Q&A Downlaod file.exe from internet.

Viewing 4 reply threads
  • Author
    Posts
    • #218958
      Participant
      Topics: 1
      Replies: 2
      Points: 17
      Rank: Member

      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.InvokeWebRequestCommand

       

      Could you help me please to understand the error?

       

    • #218970
      Participant
      Topics: 4
      Replies: 2248
      Points: 5,490
      Helping Hand
      Rank: Community MVP

      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.

    • #218973
      Participant
      Topics: 1
      Replies: 2
      Points: 17
      Rank: Member

      Thanks,

      I haven’t wrote all the script… I write it:

      $output = "C:\Users\xxxxxxx\Downloads\SW\Download\"
      $url	= "https://www.google.com/chrome/"
      Invoke-WebRequest -Uri $url -OutFile $output
      

      The output I received

      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.InvokeWebRequestCommand
      
    • #218976
      Participant
      Topics: 4
      Replies: 2248
      Points: 5,490
      Helping Hand
      Rank: Community MVP

      $output = “C:\Users\xxxxxxx\Downloads\SW\Download\”

      I assume it is a setup file you try to download. You should use something like this:

      $output = "C:\Users\xxxxxxx\Downloads\SW\Download\setup.exe"

      It should be a complete path including the file name.

    • #218985
      Participant
      Topics: 1
      Replies: 2
      Points: 17
      Rank: Member

      Oh Thanks a lot.

      It works! I thought I haven’t to write the exe file name.

      Thanks a lot again.

       

       

Viewing 4 reply threads
  • You must be logged in to reply to this topic.