Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / PowerShell / How to Disable PowerShell on Windows for Non-Admin Users

November 27, 2025

How to Disable PowerShell on Windows for Non-Admin Users

The security department has tasked my IT department with disabling PowerShell on certain computers. Users should be denied access to launch an interactive PowerShell console or execute PowerShell scripts. However, GPO logon scripts and PowerShell scripts in Task Scheduler (which run from the SYSTEM account) should still be allowed. This article will explore several methods for disabling PowerShell on computers, which can be implemented centrally via Group Policy.

The default Windows PowerShell Execution Policy is set to Restricted, which only prevents *.PS1 script files from running (can be configured via GPO option Turn on Script Execution under Computer Configuration -> Administrative Templates -> Windows Component -> Windows PowerShell). However, it doesn’t prevent users from accessing the interactive powershell.exe console.

GPO: Turn on PowerShell Script Execution

The GPO editor has a built-in policy option that lets you prevent certain executable files from running. This is policy Don’t run specified Windows applications in User Configuration -> Administrative Templates -> System. Enable the policy, click the Show button, and add the name of the executable file (powershell.exe) that you want to prevent from running.

Deny running powershell.exe executable file via GPO

After updating the GPO settings on the client device, the following error will appear if the user tries to run powershell.exe:

Restrictions
This operation has been cancelled due to restrictions in effect on this computer. Please contact your system administrator.

However, such a policy is not reliable and secure enough. For example, it didn’t prevent the launch of the Windows Terminal with a PowerShell session.

This operation has been cancelled due to restrictions in effect on this computer

Note that when implementing policies to disable PowerShell execution, multiple executable files located in different directories must be blocked:

  • x86 and x64 versions of powershell.exe and powershell_ise.exe in %SystemRoot%\System32\WindowsPowerShell\v1.0\ and %SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\ directories
  • If the new PowerShell Core version is installed on a computer, you must also prevent the pwsh.exe executable from running. For example, in my case, this path is C:\Program Files\PowerShell\7\pwsh.exe (use this command to get the path to the executable: Get-Command pwsh.exe get-command - to check executable path

You can set more flexible restrictions on running executable files using Software Restriction Policies (SRP).

  1. Create a new GPO in the AD domain using the gpmc.msc console
  2. Go to User Configuration -> Policies -> Windows Settings -> Security Settings -> Software Restriction Policies
  3. Select New Software Restriction Policy New Software Restriction Policy
  4. Go to the Additional Rules section and add the following path: %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe
  5. Set Disallowed as the security level. Deny running powershell.exe in Windows via SRP
  6. Assign the policy to the target OU

After the policy is applied, users will no longer be able to run PowerShell.exe.

 This app has been blocked by your administrator

This app has been blocked by your administrator

This SRP policy also prevents users from running the PowerShell.exe process via the Windows Terminal.

[error 2147943660 (0x800704ec) when launching `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe']

0x800704ec when launching `powershell.exe'

This program is blocked by group policy. For more information, contact your system administrator.

powershell is blocked by group policy

You can make an exception to the policy and allow certain users to use PowerShell. In this example, I created a security group in Active Directory (AD) named AllowPowerShell to which I added administrators who will be allowed to run PowerShell.

Then, open the Delegation tab in the policy settings in the GPMC console. I added this group with read access, but blocked the policy from applying: Apply Group Policy -> Deny.

exclude admin group from GPO

We prevented non-admin users from running PowerShell this way, but made an exception for the administrators. Similarly, this policy should not apply to the SYSTEM account. This will allow startup scripts and PowerShell scheduler tasks to run.

To verify that the GPO is not applied to administrators, use thegpresult /r command.

gpresult - filtering deny GPO for admins

However, starting with Windows 10 1803 and Windows Server 2019, the Software Restriction Policies feature is considered deprecated. Instead, it is recommended to use Windows Defender Application Control (WDAC) or AppLocker restriction policies.

Next, we will look at how to use an AppLocker policy to deny the running of powershell.exe. Initially, AppLocker policies could only be applied to the Enterprise edition of Windows. Starting with Windows 10 2004, AppLocker policies can be applied to Pro editions of Windows 10 and 11.

  1. To apply the AppLocker policy to the client device, enable the automatic startup for the Application Identity service (Computer Configuration -> Windows Settings -> Security Settings -> System Services) Application Identity service - autostart
  2. Then navigate to Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Application Control Policies -> AppLocker. Open the properties and enable the Configured option under Executable rules. Set the mode to Enforce rules. Enable AppLocker policy
  3. Right-click on Executable rules and select Create Default rules.
  4. In the “All files located in the Windows folder” rule, add a Publisher exception containing the path to the powershell.exe executable.
  5. Select the executable file and move the slider to File nameblock running powershell via AppLocker policy
  6. This rule prevents users from running this file.
  7. To allow administrators to run powershell.exe, you need to create a new allow rule for them. This rule should contain only this file. allow powershell to run only for admins
  8. Default Aplocker’s policies prevent users from running any executable files except those located in the Windows and Program Files folders. Therefore, if you want to prevent the launch of only PowerShell.exe, you need to add a rule that allows everything for domain users except PowerShell.exe (specify * in the path field) AppLocker rule - allow all except powershell
When creating AppLocker rules, there are a few things to consider. The default level is “Disallowed”, meaning everything is prohibited unless explicitly allowed. Rules that deny take precedence over those that permit. It means that the file allowed to run must not be explicitly blocked and must be explicitly allowed.

You can export the resulting AppLocker policy settings to an XML file to view them on a client.

Get-AppLockerPolicy -Effective -XML > C:\temp\applocker_result_policy.xml

When a user attempts to run PowerShell.exe on a client computer, a message appears informing them that the application has been blocked by the system administrator.

PowerShell blocked for users by system administrator

Likewise, the x86 and x64 versions of powershell.exe, powershell_ise.exe, and pwsh.exe should be blocked.

0 comment
1
Facebook Twitter Google + Pinterest
PowerShellQuestions and AnswersWindows 10Windows 11
previous post
Perform a Clean Installation of Windows 11: Step-by-Step Guide
next post
Start Menu Not Working (Unresponsive) on Windows Server RDS

Related Reading

Extend an Expired User Password in Active Directory

December 23, 2024

Uninstalling Windows Updates via CMD/PowerShell

April 18, 2025

Send a WhatsApp Message from the CommandLine (Shell)

December 3, 2024

How to Hide (Block) a Specific Windows Update

March 3, 2025

How to Write Logs to the Windows Event...

March 11, 2025

Run Elevated Commands with Sudo on Windows 11

August 21, 2025

How to Configure Windows Firewall Logging and Analyze...

February 17, 2025

Windows: How to Turn Off Monitor with Command...

February 17, 2025

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • AppLocker: Configure Application Restriction Policies in Windows

    November 19, 2025
  • Enable/Disable Random Hardware (MAC) Address for Wi-Fi on Windows

    November 14, 2025
  • Automate Software and Settings Deployment with WinGet Configure (DSC)

    November 13, 2025
  • SMB over QUIC: Mount File Share over Internet without VPN on Windows Server 2025

    November 4, 2025
  • How to Find a Previous Computer Name in Windows

    October 28, 2025
  • Stop Windows Server from Auto-Shutdown Every Hour

    October 22, 2025
  • How to Delete a Windows Service via CMD or PowerShell

    October 16, 2025
  • Resource Fair Sharing in Windows Server Remote Desktop Services (RDS)

    October 6, 2025
  • How to Disable (Enable) Credential Guard in Windows 11

    October 6, 2025
  • Wrong Network Profile on Windows Server after Reboot

    September 30, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Run PowerShell Scripts on a Schedule with Task Scheduler
  • How to Assign (Passthrough) a Physical GPU to a Hyper-V Virtual Machine
  • Automate Software and Settings Deployment with WinGet Configure (DSC)
  • Extend an Expired User Password in Active Directory
  • Run Elevated Commands with Sudo on Windows 11
  • Fix: Slow Startup of PowerShell Console and Scripts
  • Check Windows 11 Hardware Readiness with PowerShell Script
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top