ANAVEM
Languagefr
How to Set PowerShell Execution Policy Using Intune and Group Policy

How to Set PowerShell Execution Policy Using Intune and Group Policy

Configure PowerShell execution policies across Windows devices using Microsoft Intune and Group Policy for enterprise security and script management.

March 28, 2026 15 min
mediumpowershell 10 steps 15 min

Why Configure PowerShell Execution Policies at Enterprise Scale?

PowerShell execution policies serve as the first line of defense against malicious script execution while enabling legitimate automation and administrative tasks. In enterprise environments, managing these policies consistently across hundreds or thousands of Windows devices requires centralized deployment methods rather than manual configuration on each machine.

What Are the Different PowerShell Execution Policy Options?

PowerShell offers several execution policy levels, each providing different security postures. The Restricted policy blocks all script execution, AllSigned requires digital signatures on all scripts, RemoteSigned allows local scripts to run freely while requiring signatures for downloaded scripts, and Unrestricted permits all script execution. Understanding these options helps you balance security requirements with operational needs.

How Do Group Policy and Intune Compare for PowerShell Management?

Both Group Policy and Microsoft Intune can deploy PowerShell execution policies, but they serve different scenarios. Group Policy works best for traditional domain-joined environments with Active Directory infrastructure, providing immediate policy application and strong precedence over local settings. Intune excels in modern workplace scenarios with cloud-joined devices, offering flexibility for remote workers and BYOD environments. When both policies target the same device, Group Policy takes precedence through the MachinePolicy scope.

What Prerequisites Do You Need for Enterprise PowerShell Policy Management?

Successful deployment requires proper infrastructure and permissions. For Group Policy, you need Active Directory domain services, Group Policy Management Console, and administrative rights to create and link GPOs. Intune deployment requires Microsoft Intune licensing, Endpoint Manager access, and properly configured device groups. Both methods benefit from pilot testing groups and rollback procedures to ensure smooth production deployment.

Implementation Guide

Full Procedure

01

Install Group Policy Management Tools

First, install the Group Policy Management Console (GPMC) on your administrative workstation. This tool is essential for creating and managing Group Policy Objects.

Add-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0

Alternatively, you can install RSAT tools through Settings:

  1. Open Settings > Apps > Optional features
  2. Click "Add an optional feature"
  3. Search for "RSAT: Group Policy Management Tools"
  4. Install the feature

Verification: Run gpmc.msc to confirm the Group Policy Management Console opens successfully.

Pro tip: Install RSAT tools on a dedicated administrative workstation rather than domain controllers for better security practices.
02

Create a Group Policy Object for PowerShell Execution Policy

Launch the Group Policy Management Console and create a new GPO specifically for PowerShell execution policy management.

gpmc.msc

Follow these steps in the GPMC:

  1. Expand your domain in the left panel
  2. Right-click on "Group Policy Objects"
  3. Select "New" and name it "Set PowerShell Execution Policy"
  4. Right-click the new GPO and select "Edit"

Navigate to the PowerShell policy settings:

  1. Computer Configuration > Policies > Administrative Templates
  2. Windows Components > Windows PowerShell
  3. Double-click "Turn on Script Execution"

Verification: Confirm you can see the "Turn on Script Execution" policy in the Windows PowerShell section.

03

Configure PowerShell Execution Policy in Group Policy

Configure the execution policy settings based on your organization's security requirements. The policy offers several options that map to PowerShell execution policy levels.

In the "Turn on Script Execution" dialog:

  1. Select "Enabled"
  2. Choose your execution policy from the dropdown:
GPO OptionPowerShell PolicyDescription
Allow only signed scriptsAllSignedAll scripts must be digitally signed
Allow local scripts and remote signed scriptsRemoteSignedLocal scripts run freely, remote scripts must be signed
Allow all scriptsUnrestrictedAll scripts can execute without restrictions

For most enterprise environments, select "Allow local scripts and remote signed scripts" for balanced security.

# This is what the policy will effectively set
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

Click "Apply" then "OK" to save the configuration.

Verification: The policy status should show as "Enabled" with your selected execution policy visible in the settings summary.

Warning: Never select "Allow all scripts" in production environments unless absolutely necessary, as it removes all PowerShell security restrictions.
04

Link and Deploy the Group Policy Object

Link your GPO to the appropriate Organizational Unit (OU) to deploy the PowerShell execution policy to target computers.

Start with a test OU for validation:

  1. In GPMC, right-click your test OU (e.g., "Test Computers")
  2. Select "Link an Existing GPO"
  3. Choose "Set PowerShell Execution Policy"
  4. Click "OK"

Force policy application on test machines:

# Run on target computers
gpupdate /force

# Check policy application
gpresult /r | findstr "PowerShell"

Verify the execution policy is applied:

# Check current execution policy
Get-ExecutionPolicy

# Check all scopes to see policy hierarchy
Get-ExecutionPolicy -List

Expected output:

Scope          ExecutionPolicy
-----          ---------------
MachinePolicy  RemoteSigned
UserPolicy     Undefined
Process        Undefined
CurrentUser    Undefined
LocalMachine   Undefined

Verification: The MachinePolicy scope should show your configured execution policy, and Get-ExecutionPolicy should return the policy you set.

05

Configure PowerShell Execution Policy via Microsoft Intune

Access the Microsoft Endpoint Manager admin center to create an Intune configuration profile for PowerShell execution policy.

Navigate to https://endpoint.microsoft.com and sign in with your admin credentials.

  1. Go to Devices > Configuration profiles
  2. Click "Create profile"
  3. Select Platform: "Windows 10 and later"
  4. Profile type: "Templates" > "Administrative templates"
  5. Name: "PowerShell Execution Policy - Intune"

Configure the policy settings:

  1. Click "Configuration settings"
  2. Search for "Turn on Script Execution"
  3. Navigate to Computer Configuration > Windows Components > Windows PowerShell
  4. Enable "Turn on Script Execution"
  5. Select your desired execution policy (same options as GPO)

Verification: Confirm the policy shows as "Enabled" with your selected execution policy in the configuration summary.

Pro tip: Use descriptive names for Intune profiles that include the date and purpose, like "PowerShell-RemoteSigned-2026-03" for easier management.
06

Assign Intune Configuration Profile to Device Groups

Assign your PowerShell execution policy configuration to specific device groups in your organization.

In the profile creation wizard:

  1. Click "Assignments"
  2. Under "Included groups", click "Add groups"
  3. Select your target device groups (start with a pilot group)
  4. Configure any exclusions if needed
  5. Click "Next" to proceed

Create a test device group if you don't have one:

  1. Go to Groups > All groups > New group
  2. Group type: "Security"
  3. Group name: "PowerShell-Policy-Pilot"
  4. Membership type: "Assigned"
  5. Add test devices as members

Complete the profile deployment:

  1. Review your settings
  2. Click "Create" to deploy the profile

Verification: Check the profile status under Devices > Configuration profiles. The profile should show "Assigned" status with the number of targeted devices.

Warning: For workplace-joined devices, always use device groups rather than user groups, as user-targeted policies may not apply correctly to these devices.
07

Deploy PowerShell Scripts via Intune (Alternative Method)

As an alternative to configuration profiles, you can deploy PowerShell scripts directly through Intune to set execution policies.

Navigate to Devices > Scripts and remediations > Platform scripts:

  1. Click "Add" > "Windows 10 and later"
  2. Name: "Set PowerShell Execution Policy Script"
  3. Description: "Sets RemoteSigned execution policy via script"

Create the PowerShell script:

# PowerShell script content
try {
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force
    Write-Output "Execution policy set to RemoteSigned successfully"
    exit 0
} catch {
    Write-Error "Failed to set execution policy: $($_.Exception.Message)"
    exit 1
}

Configure script settings:

  • Run this script using the logged on credentials: No
  • Enforce script signature check: No
  • Run script in 64-bit PowerShell: Yes

Assign to the same device groups as your configuration profile for testing.

Verification: Monitor script execution under Devices > Scripts and remediations. Check the execution status and any error messages.

08

Test and Validate Policy Application

Verify that your PowerShell execution policy is correctly applied across your test devices using both Group Policy and Intune methods.

On test devices, check policy application:

# Force Intune sync
Get-ScheduledTask | Where-Object {$_.TaskName -eq "PushLaunch"} | Start-ScheduledTask

# Check execution policy
Get-ExecutionPolicy -List

# Test script execution with a simple script
$testScript = @'
Write-Host "PowerShell execution policy test successful"
Get-Date
'@

$testScript | Out-File -FilePath "C:\temp\test.ps1" -Encoding UTF8
PowerShell.exe -File "C:\temp\test.ps1"

Verify policy precedence and conflicts:

# Check which policy source is active
Get-ExecutionPolicy -List | Format-Table -AutoSize

# Check Group Policy application
gpresult /h C:\temp\gpresult.html

# Check Intune policy application
Get-WinEvent -LogName "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin" | Where-Object {$_.Message -like "*PowerShell*"}

Expected behavior: Group Policy (MachinePolicy scope) takes precedence over Intune policies when both are applied to the same device.

Verification: The test script should execute successfully, and Get-ExecutionPolicy should return your configured policy (RemoteSigned, AllSigned, or Unrestricted).

Pro tip: Use Get-ExecutionPolicy -List to understand the policy hierarchy and identify which source is setting the effective execution policy.
09

Monitor and Troubleshoot Policy Deployment

Implement monitoring and troubleshooting procedures to ensure your PowerShell execution policies are working correctly across your environment.

Monitor Group Policy application:

# Check GPO application on client
gpresult /r /scope:computer

# Generate detailed HTML report
gpresult /h C:\temp\gpo-report.html /scope:computer

# Check for Group Policy errors
Get-WinEvent -LogName "System" | Where-Object {$_.ProviderName -eq "Microsoft-Windows-GroupPolicy"}

Monitor Intune policy deployment:

  1. In Endpoint Manager, go to Devices > Configuration profiles
  2. Click your PowerShell policy profile
  3. Review "Device status" and "User status" tabs
  4. Check for any "Error" or "Conflict" statuses

Common troubleshooting commands:

# Force Group Policy refresh
gpupdate /force

# Restart Group Policy service
Restart-Service gpsvc

# Force Intune policy sync
Invoke-WmiMethod -Namespace root\cimv2\mdm\dmmap -Class MDM_EnterpriseModernAppManagement_AppManagement01 -MethodName UpdateScanMethod

# Check PowerShell event logs
Get-WinEvent -LogName "Microsoft-Windows-PowerShell/Operational" | Where-Object {$_.LevelDisplayName -eq "Error"}

Verification: Both monitoring methods should show successful policy application with no errors or conflicts reported.

10

Deploy to Production Environment

After successful testing, deploy your PowerShell execution policy configuration to your production environment using a phased approach.

For Group Policy deployment:

  1. Unlink the GPO from test OUs
  2. Link to production OUs in phases (start with less critical systems)
  3. Monitor for 24-48 hours between phases
  4. Document any issues and rollback procedures

For Intune deployment:

  1. Remove pilot device groups from assignments
  2. Add production device groups gradually
  3. Monitor deployment status in Endpoint Manager
  4. Set up automated reporting for policy compliance

Create a rollback plan:

# Emergency rollback script for local execution
Set-ExecutionPolicy -ExecutionPolicy Restricted -Scope LocalMachine -Force

# Verify rollback
Get-ExecutionPolicy -List

Set up ongoing monitoring:

# PowerShell script to check execution policy across multiple computers
$computers = Get-ADComputer -Filter * -SearchBase "OU=Production,DC=company,DC=com"

foreach ($computer in $computers) {
    try {
        $policy = Invoke-Command -ComputerName $computer.Name -ScriptBlock {Get-ExecutionPolicy} -ErrorAction Stop
        Write-Output "$($computer.Name): $policy"
    } catch {
        Write-Warning "Failed to check $($computer.Name): $($_.Exception.Message)"
    }
}

Verification: Run compliance reports to ensure all production devices have the correct execution policy applied and are functioning as expected.

Warning: Always maintain a rollback plan and test it thoroughly before production deployment. PowerShell execution policy changes can impact critical business scripts and automation.

Frequently Asked Questions

What happens when both Group Policy and Intune set different PowerShell execution policies?+
Group Policy always takes precedence over Intune when both are applied to the same device. The Group Policy setting applies through the MachinePolicy scope, which has higher priority than any Intune configuration. You can verify this by running Get-ExecutionPolicy -List to see the policy hierarchy, where MachinePolicy will show the Group Policy setting and override other scopes.
Can I set different PowerShell execution policies for PowerShell 5.1 and PowerShell 7.6?+
Group Policy and Intune administrative templates only affect Windows PowerShell 5.1 by default. PowerShell 7.6 (pwsh.exe) maintains separate execution policy settings. To manage PowerShell 7.6 policies centrally, you need to deploy custom scripts through Intune that specifically target pwsh.exe, or use the -ExecutionPolicy parameter when launching PowerShell 7.6 scripts.
How long does it take for PowerShell execution policy changes to apply via Intune?+
Intune policy application typically occurs within 8 hours for device-targeted policies, but can be faster during active device usage. You can force immediate synchronization by running the PushLaunch scheduled task or using the Sync button in the Company Portal app. Group Policy changes apply immediately during the next policy refresh cycle (every 90 minutes by default) or when running gpupdate /force.
What's the most secure PowerShell execution policy for enterprise environments?+
RemoteSigned is generally the most practical secure option for enterprise environments. It allows locally created scripts to run without signatures while requiring digital signatures for scripts downloaded from the internet. This balances security with operational flexibility, preventing most malware while allowing legitimate administrative scripts. AllSigned provides maximum security but requires code signing infrastructure for all scripts.
How can I troubleshoot PowerShell execution policy not applying correctly?+
Start by checking the policy hierarchy with Get-ExecutionPolicy -List to identify which scope is setting the policy. For Group Policy issues, run gpresult /r to verify GPO application and check the Group Policy event logs. For Intune, verify device enrollment status and check the DeviceManagement event logs. Common issues include targeting user groups instead of device groups in Intune, or conflicting local policies overriding centrally managed settings.

Discussion

Share your thoughts and insights

Sign in to join the discussion