You can inspect and statically analyze a PowerShell script without changing execution policy. First check the active policy and its scope with Get-ExecutionPolicy and Get-ExecutionPolicy -List, review the script’s contents and origin, then run PSScriptAnalyzer. These checks can reveal policy constraints and code issues, but they do not prove that unknown code is safe to run.
What execution policy does—and what it does not do
Microsoft describes execution policy as defense in depth, not a security boundary. It controls whether PowerShell loads configuration files and runs scripts; it is not a malware scanner or a guarantee of safety. A blocked script is not necessarily malicious, and a script permitted by policy is not necessarily safe.
Commands entered interactively can run regardless of execution policy, while commands launched from a script are affected. Trying a line at the prompt is therefore not the same as validating the behavior of the .ps1 file. See Microsoft’s about_Execution_Policies.
Check the policy and PowerShell version without changing anything
Run these read-only commands in the PowerShell host where you intend to work:
#1 Best Overall
Get-ExecutionPolicy
Get-ExecutionPolicy -List
$PSVersionTable.PSVersion
The first command reports the effective policy. The second shows values by scope; MachinePolicy or UserPolicy can indicate a Group Policy setting that takes precedence over locally set policy. The version command helps distinguish Windows PowerShell 5.1 from PowerShell 7 and later.
Policy behavior depends on platform and host. Windows client and Windows Server defaults differ. Since PowerShell 6, non-Windows systems default to Unrestricted, and Set-ExecutionPolicy cannot change policy there. Windows PowerShell 5.1 and PowerShell 6+ manage policy settings separately. Consult Microsoft’s Get-ExecutionPolicy and Set-ExecutionPolicy documentation for the relevant host.
Review the script before considering execution
Open the script as text and check who supplied it, where it came from, and what it does. Pay particular attention to commands that modify files, accounts, permissions, services, registry settings, network configuration, or other system state. Also inspect any scripts, modules, or downloads it invokes; reviewing only the top-level file may miss behavior delegated elsewhere.
For a file marked as downloaded, distinguish its file block from execution policy. Microsoft recommends reading and verifying the code before using Unblock-File. That cmdlet removes the downloaded-file block; it does not change execution policy, and it is not a safety test. A file may still be subject to applicable policy after unblocking.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteRank #3
- Used Book in Good Condition
Run static analysis with PSScriptAnalyzer
PSScriptAnalyzer is Microsoft’s static code checker for PowerShell scripts and modules. It analyzes .ps1, .psm1, and .psd1 files and reports findings against its rules. Compatibility rules can also flag commands, cmdlets, syntax, or types that may not be available in another PowerShell environment. Static analysis does not execute the script and is not a runtime sandbox.
After installing or making the official PSScriptAnalyzer module available for your platform, analyze a script with:
Rank #4
Invoke-ScriptAnalyzer -Path .YourScript.ps1
Review each finding in context; a clean report is not proof that the script is harmless. If you use the analyzer’s -Fix option, work from a backup: Microsoft notes that fixes modify files and can affect encoding in some cases. See the official PSScriptAnalyzer overview.
Test runtime behavior in a controlled environment
Static checks cannot show every effect that will occur when code runs. If you need to observe runtime behavior—especially for a script that changes system state—use an appropriately isolated, disposable virtual machine or another controlled environment. The right setup depends on what the script does and the systems it can reach; execution-policy documentation does not provide a universal sandbox or guarantee that a particular environment contains every side effect.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesBest Value
- Use a disposable environment rather than a machine containing important data or credentials.
- Keep the test environment’s access to networks, shared folders, and host resources limited to what the test requires.
- Observe the files, services, settings, and external connections the script touches, and discard or restore the environment afterward.
Understand the scopes before any policy adjustment
If you eventually determine that a policy change is necessary, understand its reach and precedence first. LocalMachine is the default scope for Set-ExecutionPolicy and affects all users; changing it requires an elevated PowerShell session. CurrentUser affects only the current user. Process applies to the current session and child sessions, then disappears when that process closes. Group Policy settings can override locally set policy.
| Scope | Reach and persistence |
|---|---|
Process |
Current PowerShell session and child sessions; discarded when the process closes. |
CurrentUser |
Applies to the current user. |
LocalMachine |
Applies to all users; changing it requires elevation. |
MachinePolicy / UserPolicy |
Group Policy scopes; take precedence over locally set policy. |
A temporary Process setting only limits how long the setting lasts; it does not validate the script or bypass Group Policy. Do not use Bypass as a safety measure: Microsoft says that policy blocks nothing and displays no warnings or prompts. For scope and precedence details, see Set-ExecutionPolicy.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




