I would not be surprised if this is not possible, but I need to set the execution policy (on the 32 bit PowerShell environment) on several build servers - it would be much quicker if I could script this, but my current attempt,
%SystemRoot%\syswow64\WindowsPowerShell\v1.0\
powershell.exe -Version 2
-Command "& {Set-ExecutionPolicy -ExecutionPolicy RemoteSigned}"
completes without any visible error, but the execution policy is not being set.
I guess it would create a bit of a security hole if users could be tricked into running a script that changed their execution policy, but I thought I would ask the question anyway.
OK - so Richard and Craika are entirely correct and I am a little bit stupid. After retrying the command - I find that it does work (despite what I said in the question). I guess I must have been getting mixed up between 32 and 64 PowerShell windows (i.e. setting the execution policy in one and then checking the value in another).
Apologies.