Set-ExecutionPolicy -Scope CurrentUser unrestricted
Set-ExecutionPolicy -Scope LocalMachine unrestricted
With this changes above we can now execute scripts like this
./our_script.ps1
Here is the code for download a software and install it
## ExampleURL https://github.com/lukehaas/RunJS/releases/download/v2.9.0/RunJS-Setup-2.9.0.exe
$downloadUrl = "DIRECT_URL_TO_DOWNLOAD"
$fileName = [System.IO.Path]::GetFileName($downloadUrl)
$fileNameWithoutExtension = $fileName -replace '\.exe$'
$destinationPath = Join-Path $env:TEMP "$fileNameWithoutExtension.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $destinationPath
Start-Process -FilePath $destinationPath -Wait
Remove-Item $destinationPath
## Once the software is installed, you can remove the execution policy
Set-ExecutionPolicy -Scope CurrentUser restricted
Set-ExecutionPolicy -Scope LocalMachine restricted
I highly recommend using chocolatey
for managing software in windows enviroments. Here is their webpage