$url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win32-x86_64/tclsh902z.exe" $outbase = $PSScriptRoot $outbase = Resolve-Path -Path $outbase #expected script location is the bin folder of a punk project $rtfolder = Join-Path -Path $outbase -ChildPath "runtime" #$output = "$(join-path $PSScriptRoot "..\src\runtime\tclsh902z.exe")" $output = "$(join-path $rtfolder "win32-x86_64\tclsh902z.exe")" $container = split-path -Path $output -Parent new-item -Path $container -ItemType Directory -force #create with intermediary folders if not already present if (-not(Test-Path -Path $output -PathType Leaf)) { Write-Host "Downloading from $url ..." Invoke-WebRequest -Uri $url -OutFile $output Write-Host "Runtime saved at $output" } else { Write-Host "Runtime already found at $output" }