Turn on Script Execution
Activer l’exécution des scripts
Explanation
This policy setting lets you configure the script execution policy, controlling which scripts are allowed to run.
If you enable this policy setting, the scripts selected in the drop-down list are allowed to run.
The "Allow only signed scripts" policy setting allows scripts to execute only if they are signed by a trusted publisher.
The "Allow local scripts and remote signed scripts" policy setting allows any local scrips to run; scripts that originate from the Internet must be signed by a trusted publisher.
The "Allow all scripts" policy setting allows all scripts to run.
If you disable this policy setting, no scripts are allowed to run.
Note: This policy setting exists under both "Computer Configuration" and "User Configuration" in the Local Group Policy Editor. The "Computer Configuration" has precedence over "User Configuration."
If you disable or do not configure this policy setting, it reverts to a per-machine preference setting; the default if that is not configured is "No scripts allowed."
Ce paramètre de stratégie vous permet de configurer la stratégie d’exécution de scripts en déterminant quels scripts peuvent être exécutés.
Si vous activez ce paramètre de stratégie, l’exécution des scripts sélectionnés dans la liste déroulante est autorisée.
Le paramètre de stratégie « Autoriser uniquement les scripts signés » permet uniquement l’exécution des scripts signés par un éditeur approuvé.
Le paramètre de stratégie « Autoriser les scripts locaux et les scripts signés distants » permet l’exécution de tous les scripts locaux. Les scripts provenant d’Internet doivent être signés par un éditeur approuvé.
Le paramètre de stratégie « Autoriser tous les scripts » permet l’exécution de tous les scripts.
Si vous désactivez ce paramètre de stratégie, aucun script ne peut être exécuté.
Remarque : ce paramètre de stratégie est présent sous « Configuration ordinateur » et « Configuration utilisateur » dans l’Éditeur d’objets de stratégie de groupe. La « Configuration ordinateur » a priorité sur la « Configuration utilisateur ».
Si vous désactivez ou ne configurez pas ce paramètre de stratégie, il redevient un paramètre de préférence par ordinateur. S’il n’est pas configuré, sa valeur par défaut est « Aucun script autorisé ».
Use cases
Sets the PowerShell execution policy by GPO: "allow only signed scripts" (AllSigned), "allow local scripts and remote signed scripts" (RemoteSigned) or "allow all scripts". When disabled, no scripts run.
Execution policy is a safeguard against accidental execution, not a security boundary: combine it with App Control or AppLocker. Computer Configuration settings take precedence over User Configuration settings.
Microsoft source: about_Group_Policy_Settings
Registry
HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShellHKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\PowerShell- Value name
EnableScripts
| State | Value written |
|---|---|
| Enabled | REG_DWORD = 1 |
| Disabled | REG_DWORD = 0 |
PowerShell
PowerShell commands that write to the registry what the policy would write. Values in angle brackets (<…>) must be replaced.
Writing directly to the registry bypasses Group Policy: if a GPO manages this value, it will be rewritten at the next gpupdate; otherwise the value stays in place (the "tattooing" effect). Prefer a GPO or, locally, LGPO.exe. Run PowerShell as administrator for HKLM. Some policies need a restart or gpupdate /force.
Computer (HKLM)
Enable
# Enable: PowerShellExecutionPolicy/EnableScripts
$k = 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
Set-ItemProperty -Path $k -Name 'EnableScripts' -Value 1 -Type DWord
# Execution Policy
# Possible options:
# Allow only signed scripts = AllSigned
# Allow local scripts and remote signed scripts = RemoteSigned
# Allow all scripts = Unrestricted
Set-ItemProperty -Path $k -Name 'ExecutionPolicy' -Value 'AllSigned' -Type StringDisable
# Disable: PowerShellExecutionPolicy/EnableScripts
$k = 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
Set-ItemProperty -Path $k -Name 'EnableScripts' -Value 0 -Type DWordRevert to "Not configured"
# Revert to "Not configured": PowerShellExecutionPolicy/EnableScripts
$k = 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell'
Remove-ItemProperty -Path $k -Name 'EnableScripts' -ErrorAction SilentlyContinue
Remove-ItemProperty -Path $k -Name 'ExecutionPolicy' -ErrorAction SilentlyContinueUser (HKCU)
Enable
Disable
Revert to "Not configured"
Options (1)
| Label | Control | Registry value | REG type | Constraints / details | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Execution PolicyStratégie d’exécutionExecutionPolicy | Drop-down listenum | ExecutionPolicy | REG_SZ | Required
|