I've been trying to launch a simple powershell script from a batch file. After looking online the advice is to set the policy using Set-ExecutionPolicy.
I've done this and using Get-ExecutionPolicy the policy has been changed.
However running this batch file results in an 'Open With' dialog rather than the execution of the script.
Batch:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe ^&'./script.psl'
Powershell:
Write-Host "This is a message"
I have sampled on both Windows 7 and Server 2008 R2. Both have same result. What am I missing?
To run a script file from the command line, use the -file parameter of powershell.exe.
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -file './script.psl'