I have a powershell script that is started bij a jenskinsfile. This all works well. But in the script I have a function to download a file. This does not work, because the $filePath variable contains the value twice. When this part would be run the log would look like:
https://example.com/api/download
D:\folder\file_2.txt D:\folder\file_2.txt
How can I get the value only to be there ones in $filePath ?
function DownloadFile ($folder, $version) {
$wc = New-Object System.Net.WebClient
$wc.Headers['Content-Type'] = 'application/json'
$requesturl = "https://example.com/api/download"
$filePath = Join-Path -Path $folder -ChildPath "\file_$version.txt"
Write-Host "$requesturl"
Write-Host "$filePath"
$wc.DownloadFile($requesturl, $filePath)
return $filePath
}