Jump to content


  • 0
KuifJe

Powershell Executionpolicy

Question

Hi there,

 

I have a Windows Server 2008 R2 task sequence running flawlessly. Installing applications and App-V packages, adding to the proper domain and OU.

 

Recently we created a script changing some settings with powershell. To be able to run this script in the tasksequence I'm trying to change the execution policy to 'unrestricted'. We have a policy in place to change the execution policy to 'RemoteSigned' but this policy is applied at the end of the tasksequence.

 

To change the policy I've added a command line entry in the task sequence with the following command: cmd /c Powershell.exe -Command Set-ExecutionPolicy Unrestricted

 

This command works properly when I run it from a CMD prompt, however it has no effect when run during the task sequence.

 

I've browsed through the SMSTS.log file and I see the commandline being built and called with the smsswd.exe tool, it seems to run properly and finish as it should, but after checking the policy setting in Powershell it's still on 'Restricted'

 

Any thoughts or ideas?

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Have you tried disabling 64bit redirection on the task? I'm not sure if that is causing your problem, but I always tick that box when I'm trying to make a systemwide change... just to make sure something isn't redirected since ccm is a 32bit process.

Share this post


Link to post
Share on other sites

  • 0

This is old now but i have had success prepending it in my command line. as in:

powershell.exe -noprofile set-executionpolicy remotesigned -force;.\MyScript.ps1; exit $LASTEXITCODE

 

this sets the exec policy, runs the script and returns the LASTEXITCODE to sccm.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.