Open in the explorer

Turn on Module Logging

Activer l’enregistrement des modules

Type
Computer and user
GPO path
Computer Configuration › Policies › Administrative Templates › Windows Components › Windows PowerShell User Configuration › Policies › Administrative Templates › Windows Components › Windows PowerShell FR: Configuration ordinateur › Stratégies › Modèles d'administration › Composants Windows › Windows PowerShellFR: Configuration utilisateur › Stratégies › Modèles d'administration › Composants Windows › Windows PowerShell
Supported on
At least Microsoft Windows 7 or Windows Server 2008 family FR: Au moins Microsoft Windows 7 ou famille Windows Server 2008
ADMX file
PowerShellExecutionPolicy.admx
Internal name
PowerShellExecutionPolicy/EnableModuleLogging

Explanation

This policy setting allows you to turn on logging for Windows PowerShell modules.

If you enable this policy setting, pipeline execution events for members of the specified modules are recorded in the Windows PowerShell log in Event Viewer. Enabling this policy setting for a module is equivalent to setting the LogPipelineExecutionDetails property of the module to True.

If you disable this policy setting, logging of execution events is disabled for all Windows PowerShell modules. Disabling this policy setting for a module is equivalent to setting the LogPipelineExecutionDetails property of the module to False.

If this policy setting is not configured, the LogPipelineExecutionDetails property of a module or snap-in determines whether the execution events of a module or snap-in are logged. By default, the LogPipelineExecutionDetails property of all modules and snap-ins is set to False.

To add modules and snap-ins to the policy setting list, click Show, and then type the module names in the list. The modules and snap-ins in the list must be installed on the computer.

Note: This policy setting exists under both Computer Configuration and User Configuration in the Group Policy Editor. The Computer Configuration policy setting takes precedence over the User Configuration policy setting.

French text from Windows 11 26H2

Ce paramètre de stratégie vous permet d’activer ou de désactiver l’enregistrement des modules Windows PowerShell.

Si vous activez ce paramètre de stratégie, les événements d’exécution du pipeline pour les membres des modules spécifiés sont enregistrés dans le journal Windows PowerShell de l’observateur d’événements. L’activation de ce paramètre de stratégie pour un module revient en fait à attribuer la valeur True à la propriété LogPipelineExecutionDetails du module.

En désactivant ce paramètre de stratégie, vous désactivez également l’enregistrement des événements d’exécution pour tous les modules Windows PowerShell. La désactivation de ce paramètre de stratégie pour un module revient en fait à attribuer la valeur False à la propriété LogPipelineExecutionDetails du module.

Si vous ne configurez pas ce paramètre de stratégie, la propriété LogPipelineExecutionDetails d’un module ou d’un composant logiciel enfichable détermine si les événements d’exécution d’un module ou d’un composant logiciel enfichable sont enregistrés. Par défaut, la propriété LogPipelineExecutionDetails de tous les modules et composants logiciels enfichables est définie sur False.

Pour ajouter des modules et des composants logiciels enfichables à la liste des paramètres de stratégie, cliquez sur Afficher, puis entrez les noms des modules dans la liste. Vous devez installer les modules et les composants logiciels enfichables sur l’ordinateur.

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. Le paramètre de stratégie de Configuration ordinateur a priorité sur celui de Configuration utilisateur.

Use cases

Records pipeline execution events for the modules you list (for example "*" for all). It complements script block logging by showing the cmdlets called and their parameters.

If the policy is not configured, each module's LogPipelineExecutionDetails property decides (off by default); when disabled, no events are logged.

Microsoft sources: about_Group_Policy_Settings · about_Logging_Windows

Registry

HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging
Value name
EnableModuleLogging
StateValue written
EnabledREG_DWORD = 1
DisabledREG_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/EnableModuleLogging
$k = 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
Set-ItemProperty -Path $k -Name 'EnableModuleLogging' -Value 1 -Type DWord
$k = 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging\ModuleNames'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
# Module Names
# Non-additive list: existing values of the key are cleared first
if (Test-Path -Path $k) { (Get-Item -Path $k).Property | ForEach-Object { Remove-ItemProperty -Path $k -Name ([WildcardPattern]::Escape($_)) -ErrorAction SilentlyContinue } }
$values = @('<value1>', '<value2>')  # Replace the values with your own
foreach ($v in $values) { Set-ItemProperty -Path $k -Name $v -Value $v -Type String }

Disable

# Disable: PowerShellExecutionPolicy/EnableModuleLogging
$k = 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
Set-ItemProperty -Path $k -Name 'EnableModuleLogging' -Value 0 -Type DWord

Revert to "Not configured"

# Revert to "Not configured": PowerShellExecutionPolicy/EnableModuleLogging
$k = 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging'
Remove-ItemProperty -Path $k -Name 'EnableModuleLogging' -ErrorAction SilentlyContinue
$k = 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ModuleLogging\ModuleNames'
Remove-Item -Path $k -Recurse -Force -ErrorAction SilentlyContinue

User (HKCU)

Enable

Disable

Revert to "Not configured"

Options (1)

LabelControlRegistry valueREG typeConstraints / details
Module NamesNoms des modulesListbox_ModuleNamesList (table)listSoftware\Policies\Microsoft\Windows\PowerShell\ModuleLogging\ModuleNamesNumbered values (1, 2, 3…)REG_SZ (values under the key)

Availability