r/PowerShell • u/TotalGameControl • Mar 23 '26
Question how do i enable script block logging and what is it?
someone recommended i enabled it but i can’t find any reliable information on how to enable it? i’m getting different info depending on what source i go to
1
Upvotes
2
u/Th3Sh4d0wKn0ws Mar 23 '26
what sources are giving you conflicting info?
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_logging_windows?view=powershell-7.5#enabling-scriptblock-logging
As u/justaguyonthebus said, enable it per the Microsoft Docs then you can view the logs in Event Viewer.
When someone recommended that you enable this, was there more context to this? Is this just your personal computer? A work computer? Are you looking for something, or just trying to establish more auditing?
4
u/justaguyonthebus Mar 23 '26 edited Mar 23 '26
about_Logging_Windows - PowerShell | Microsoft Learn https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_logging_windows?view=powershell-7.5
It logs to the windows event log what code is about to be ran before it runs. More of a security audit feature.
Edit: fixed shady looking link
2
u/m0rgenthau Mar 23 '26
That's weird, it's a very well documented topic.
Link to a trustworthy source that describes the reasoning and how to configure it via registry or GPO: https://www.stigviewer.com/stigs/microsoft-windows-11-security-technical-implementation-guide/2025-05-15/finding/V-253414