Skip to content

Powershell Executionpolicy

Featured Replies

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?

  • 11 months later...
  • 3 months later...

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.

  • 7 months later...

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.

Join the conversation

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

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.