I'm trying to write a powershell script that will download an exe from a specified URL (passed through as a parameter at the time of calling the script)
The code I have:
Param(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true)]
[String]
$cwdl
)
Start-Job -Name WebReq -ScriptBlock { Invoke-WebRequest $cwdl -OutFile "C:\MYFILEPATH\cw.exe" }
Wait-Job -Name WebReq
If I replace the $cwdl with "mypathtoexefile" then it works. But with the $cwdl variable it does nothing. I've even tried statically setting $cwdl as either $cwdl = 'mypathtoexefile' and $cwdl = "mypathtoexefile" but nothing I've tried is allowing the Invoke-WebRequest to resolve the filepath if I'm using a variable, regardless of if it's generated by the parameter.