0

I am trying to download file from the web using following command

Invoke-WebRequest $url -OutFile $filePath -Headers $Headers

I have argument, which contains this url and it is passed as parameter

[string]$artifactHttpAddress = $args[2]

Currently its value is

http://10.45.48.26/httpAuth/repository/downloadAll/TeamCityTest_Build/529:id/artifacts.zip

So, when I try to invoke WebRequest with following command
Invoke-WebRequest $artifactHttpAddress -OutFile c:/test.zip -Headers $Headers

it is downloading empty zip file .

but when I try to assign this url to the variable and invoke web request

$url = "http://10.45.48.26/httpAuth/repository/downloadAll/TeamCityTest_Build/529:id/artifacts.zip"
Invoke-WebRequest  $url -OutFile   c:/test.zip  -Headers $Headers

It is working correctly, downloads zip file, which have some content in it.

I tried following script

Write-Host([string]$url -eq [string]$artifactHttpAddress) 
Write-Host([string]$url) 
Write-Host([string]$artifactHttpAddress) 

It outputs

 False
 http://10.45.48.26/httpAuth/repository/downloadAll/TeamCityTest_Build/528:id/artifacts.zip
 http://10.45.48.26/httpAuth/repository/downloadAll/TeamCityTest_Build/531:id/artifacts.zip

What is happening and why?

p.s. this script is inside ScriptBlock

1 Answer 1

2

It looks to me, based on your output, that $url and $artifactHttpAddress are not the same value. Does the ZIP file exist at the URL with 531 in it?

Sign up to request clarification or add additional context in comments.

1 Comment

That was issue I think, missed difference between urls

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.