Learner
Learner

Reputation: 483

How to download a zipped file from internet on to a Windows machine using PowerShell via Ansible?

I have a situation where i want to download an artifact which is a zipped folder from an internet to the windows machine using ansible. I am doing as follows:

 win_command: "Invoke-WebRequest -Uri "http://abc/sample.zip" -OutFile "C:/Share/sample.zip "

But the above piece is not working at all, so could you please suggest what am I doing wrong? Did I use a wrong syntax of win_command or the PowerShell command is wrong?

Upvotes: 2

Views: 678

Answers (2)

user7377479
user7377479

Reputation:

You can use it like this:

win_command: "Invoke-WebRequest -Uri 'http://abc/sample.zip' -OutFile 'C:/Share/sample.zip'"

Remember to use correct single quotation and double quotation correctly.

Upvotes: 2

techraf
techraf

Reputation: 68539

There is a Windows module win_get_url for downloading files from web.

For example:

- name: Ensure the file is downloaded
  win_get_url:
    url: http://abc/sample.zip
    dest: C:\Share\sample.zip
    force: no

Upvotes: 2

Related Questions