My friend called me from his small business the other day wanting to run a PowerShell script on Windows. This was for testing cleaning up cache files from Windows updates. After taking a walk in Brooklyn and brewing my favorite Caturra coffee at home I decided to take on this one.

After you write your script you need to set the execution policy:

PowerShell’s execution policy determines the conditions under which PowerShell loads configuration files and runs scripts. By default, the execution policy is set to restrict running scripts. You need to change this setting to run your script.

Open PowerShell as Administrator:

  • Press Win + X to open the Power User menu.
  • Select Windows PowerShell (Admin) or Windows PowerShell.

Check Current Policy:


Set Execution Policy: Change the policy to allow script execution. There are several policies you can set:

  • RemoteSigned: Requires that all scripts and configuration files downloaded from the internet be signed by a trusted publisher.
  • Unrestricted: Allows all scripts to run.

To set the policy to RemoteSigned:

Set-ExecutionPolicy RemoteSigned

If prompted, confirm the change by typing Y and pressing Enter.

Run the PowerShell Script

Use the cd (Change Directory) command to navigate to the directory where your script is saved.

To run the script, type .\ followed by the script name. For example:


Leave a comment

Your email address will not be published. Required fields are marked *