views:

260

answers:

3

Hi,

I have a signed PowerShell script which I want to deploy to a target machine via a WiX installer. Is it possible to give the script the execution rights?

Regards, forki

  • EDIT - It seems I have to call Powershell with --Command Set-ExecutionPolicy RemoteSigned, but I can't get it working. I see the Powershell command window opening but it doesn't change the policy.
<Property Id="POWERSHELLEXE"><![CDATA[C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe]]></Property>

<CustomAction Id="AllowPS"
  Property="POWERSHELLEXE"
  ExeCommand="-NoLogo -NoProfile -Command Set-ExecutionPolicy RemoteSigned"
  Execute="deferred"
  Return="check"/>

<InstallExecuteSequence>
   ..
  <Custom Action="AllowPS" Before="InstallFinalize"/>
   ...
</InstallExecuteSequence>
+1  A: 

If you are using PowerShell 2.0, there is a -ExecutionPolicy parameter on PowerShell.exe. Try something like this in one single custom action to run the script.

ExeCommand="-NoLogo -NoProfile -ExecutionPolicy RemotedSigned -File <scrptpath>"
Keith Hill
+1  A: 

I will set the ExecutionPolicy via group policies.

forki23
+2  A: 

Group Policy is the better way to go about it,

I think the reason that your call to PowerShell.exe is not changing the execution policy is because the cmdlet is set to prompt the user before changing the execution policy. The -Force parameter will force the change without an additional prompt.

Steven Murawski