3

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>
3
  • It seems I have to call Powershell with --Command Set-ExecutionPolicy RemoteSigned, but I can't get it working. Commented Mar 5, 2010 at 12:37
  • Are you using PowerShell 1.0 or 2.0 on the target machine? Commented Mar 5, 2010 at 16:24
  • We have Win 7 - so I think it's 2.0. Commented Mar 5, 2010 at 16:32

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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 RemoteSigned -File <scrptpath>"

1 Comment

You've got a typo - should be 'RemoteSigned'
1

I will set the ExecutionPolicy via group policies.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.