en-US windows computer user

Run Windows PowerShell scripts first at user logon, logoff

Verified with Windows 11 25H2 — updated on July 30, 2026

Windows 11 25H2

Supported on: At least Windows Server 2008 R2 or Windows 7

Path in the GPO console

Computer Configuration\Administrative Templates\System\Scripts

Description

This policy setting determines whether Windows PowerShell scripts are run before non-Windows PowerShell scripts during user logon and logoff. By default, Windows PowerShell scripts run after non-Windows PowerShell scripts. If you enable this policy setting, within each applicable Group Policy Object (GPO), PowerShell scripts are run before non-PowerShell scripts during user logon and logoff. For example, assume the following scenario: There are three GPOs (GPO A, GPO B, and GPO C). This policy setting is enabled in GPO A. GPO B and GPO C include the following user logon scripts: GPO B: B.cmd, B.ps1 GPO C: C.cmd, C.ps1 Assume also that there are two users, Qin Hong and Tamara Johnston. For Qin, GPOs A, B, and C are applied. Therefore, the scripts for GPOs B and C run in the following order for Qin: Within GPO B: B.ps1, B.cmd Within GPO C: C.ps1, C.cmd For Tamara, GPOs B and C are applied, but not GPO A. Therefore, the scripts for GPOs B and C run in the following order for Tamara: Within GPO B: B.cmd, B.ps1 Within GPO C: C.cmd, C.ps1 Note: This policy setting determines the order in which user logon and logoff scripts are run within all applicable GPOs. You can override this policy setting for specific script types within a specific GPO by configuring the following policy settings for the GPO: User Configuration\Policies\Windows Settings\Scripts (Logon/Logoff)\Logon User Configuration\Policies\Windows Settings\Scripts (Logon/Logoff)\Logoff This policy setting appears in the Computer Configuration and User Configuration folders. The policy setting set in Computer Configuration takes precedence over the setting set in User Configuration.

Registry

HKLM Software\Microsoft\Windows\CurrentVersion\Policies\System
HKCU Software\Microsoft\Windows\CurrentVersion\Policies\System

Value name: RunUserPSScriptsFirst

Enabled: RunUserPSScriptsFirst = 1

Disabled: RunUserPSScriptsFirst = 0

MDM / Intune (CSP)

Device ./Device/Vendor/MSFT/Policy/Config/ADMX_Scripts/Run_User_PS_Scripts_First
User ./User/Vendor/MSFT/Policy/Config/ADMX_Scripts/Run_User_PS_Scripts_First
DeviceUser Since Windows 10, version 2004 with KB5005101 [10.0.19041.1202] and later | Windows 10, version 20H2 with KB5005101 [10.0.19042.1202] and later | Windows 10, version 21H1 with KB5005101 [10.0.19043.1202] and later | Windows 11, version 21H2 [10.0.22000] and later Official mapping (Microsoft Learn)

Microsoft Learn documentation Mapping data: Microsoft Learn (CC BY 4.0)

Export Builder

BETA

Configure the state, scope and options, then generate .reg, PowerShell, Intune and SCCM outputs — or add the setting to a multi-setting collection.

These exports write the registry — this is not a managed GPO.

Scope

.reg file

Windows Registry Editor Version 5.00

; Exported from gporais.com
; Policy: Run Windows PowerShell scripts first at user logon, logoff
; State: Enabled
; Scope: Computer (HKLM)
; Supported on: At least Windows Server 2008 R2 or Windows 7

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System]
"RunUserPSScriptsFirst"=dword:00000001
More formats (PowerShell, Intune, SCCM)

PowerShell

# Exported from gporais.com
# Policy: Run Windows PowerShell scripts first at user logon, logoff
# State: Enabled
# Scope: Computer (HKLM)
# Supported on: At least Windows Server 2008 R2 or Windows 7

$path = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System'
New-Item -Path $path -Force | Out-Null
Set-ItemProperty -Path $path -Name 'RunUserPSScriptsFirst' -Value 1 -Type DWord

Building a multi-setting collection? Add this setting and generate combined .reg / PowerShell / GPO scripts.

Open the Builder

Embed this policy on your site

What to embed
Theme

Adds one script line: the theme follows your site’s appearance and the height fits the content. If your site blocks scripts, the embed follows the visitor’s system theme.

Preview