πŸ›‘οΈ Admin Required

PowerShell Script Execution Policy - Simple User Guide

This page explains what scripts are, what PowerShell is, why execution policy matters, and the exact commands to check or change it. Every command includes a Copy button so users can copy-paste safely.

⚠️ Important: You must open PowerShell as Administrator, and you must be signed in with an account that has admin rights. Otherwise, many script and policy changes will not work.

πŸ”‘ Step 1: Open PowerShell as Administrator (Admin Mode)

You can access PowerShell by either searching for it or using Win + X and selecting Terminal (Admin).

1) Open Search

Press Windows + S (or click the search bar).

2) Search PowerShell

Type PowerShell.

3) Run as Administrator

Right-click Windows PowerShell β†’ select Run as Administrator.

4) Accept the prompt

If you see a UAC prompt, click Yes.

🚫 If you are not an admin: some commands will fail (especially when using -Scope LocalMachine).

🧭 Step 2: Check your current Execution Policy

The execution policy is a safety feature in PowerShell. It controls whether scripts are allowed to run. This command shows what your system is currently set to.

🧾 Command: Check current policy Safe to run
Get-ExecutionPolicy
What it does: Shows your current script permission level (for example: Restricted or RemoteSigned).

🧩 Step 3: Change Execution Policy (Enable or Disable Scripts)

Use these commands to control whether scripts can run. For most users, RemoteSigned is the best balance. The -Scope CurrentUser option changes it for your user account only (safer and usually does not require full system changes).

βœ… Recommended: Allow scripts (Current User)

This allows scripts you created locally to run, but downloaded scripts must be signed.

βœ… Enable scripts (Recommended) Typical choice
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
What it does: Lets your account run local scripts. Helps protect you from risky downloaded scripts.

πŸ”’ Disable all scripts (Most restrictive)

Use this if you want to block scripts completely.

πŸ”’ Disable scripts High security
Set-ExecutionPolicy Restricted -Scope CurrentUser
What it does: Blocks all scripts. Useful on locked-down PCs, but your own maintenance scripts will not run.

πŸ’Ύ Step 4: Save a PowerShell (.ps1) Script

A .ps1 file is a PowerShell script file that contains a series of commands. To create and save a script:

βœ… Save the script as a .ps1 file:

  1. Open Notepad or any text editor.
  2. Write your PowerShell commands in the editor.
  3. Click File β†’ Save As.
  4. Choose a location to save the file, and type script.ps1 in the File name field.
  5. Ensure the Save as type is set to All Files.
  6. Click Save.

Example .ps1 script:


      # Example PowerShell Script to Enable RemoteSigned Policy
      Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
      

βœ… How to run the .ps1 script:

1. Navigate to the folder where your .ps1 file is saved in PowerShell:

πŸ“‚ Change directory
cd "C:\path\to\your\script\

2. Run the script:

πŸš€ Run Script
.\script.ps1
Reminder: You need to be in the same folder as your .ps1 file to run it successfully.

🧯 Step 5: Set Execution Policy for All Users (System-wide)

This affects the whole computer. It usually requires admin privileges. Only do this if you manage the machine and understand the impact.

🌍 RemoteSigned for all users Admin required
Set-ExecutionPolicy RemoteSigned -Scope LocalMachine
What it does: Sets the policy for the entire system (every user account). Use carefully.

↩️ Revert to default (Restricted)

↩️ Restricted for all users Admin required
Set-ExecutionPolicy Restricted -Scope LocalMachine

🧩 Optional: Use a PowerShell Profile (Advanced)

A PowerShell profile is a script that runs automatically every time PowerShell opens. You can use it to set your preferred policy each time.

πŸ“‚ Open your profile file

πŸ“ Open profile in Notepad Safe to run
notepad.exe $PROFILE

βž• Add this line to set RemoteSigned on startup

βž• Add to profile Use carefully
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

🧾 Quick Summary (Copy-friendly)

Open PowerShell (Admin)

Search β€œPowerShell” β†’ Right-click β†’ Run as Administrator.

Check policy
🧾 Get current policy
Get-ExecutionPolicy
Recommended enable (CurrentUser)
βœ… RemoteSigned
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Disable scripts
πŸ”’ Restricted
Set-ExecutionPolicy Restricted -Scope CurrentUser
βœ…
Copied to clipboard
Command copied