Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-2500

DSC - PowerShell Process Execution Policy is ignored

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • None
    • dsc
    • Windows 10
      PowerShell v5
      Execution Policy set to Restricted

    • 1
    • Windows 2015-09-09

    Description

      PowerShell DSC uses the machine execution policy when calling PowerShell scripts. If the default "Restricted" policy is set (use Get-ExecutionPolicy to determine), it means it will error. It completely ignores what you start up PowerShell with.

      Consider the following manifest:

      dsc_xgroup {'testgroup':
        dsc_ensure          => 'present',
        dsc_groupname       => 'TestUsers',
        dsc_members         => 'vagrant',
      }
      

      and Get-ExecutionPolicy returns "Restricted"

      Running it in dsc, which calls PowerShell.exe with -ExecutionPolicy Bypass (I also tried setting it to Unrestricted, but no dice) produces the following:

      Error: /Stage[main]/Main/Dsc_xgroup[testgroup]: Could not evaluate: Importing module MSFT_xGroupResource failed with
       error - File C:\Program 
      Files\WindowsPowerShell\Modules\PuppetVendoredModules\xPSDesiredStateConfiguration\DscResources\MSFT_xGroupR
      esource\MSFT_xGroupResource.psm1 cannot be loaded because running scripts is disabled on this system. For more 
      information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
      

      Attachments

        Issue Links

          Activity

            People

              ryan.gard Ryan Gard
              rob Rob Reynolds
              Ryan Gard Ryan Gard
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support