Undo PowerShell Redirect

Nakkie Swanepoel 20 Reputation points
2023-09-06T17:17:05.39+00:00

So I did a dumb and ran the below script as is in PowerShell

PowerShell > Set-ExecutionPolicy Unrestricted

I wasn't paying attention and did not remove the PowerShell > portion of the command.
Now every command I run prints the output to file.
Every file contains the exact same error.


I am for the life of me unable to revert this fubar error I made.
Any assistance would be greatly appreciated.

General Notes

  • This only happens when I run PowerShell as admin
  • Running PowerShell normally executes the command as expected
PS C:\Users\myuser> Set-ExecutionPolicy Unrestricted
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"):
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 36,291 Reputation points
    2023-09-06T17:52:52.0266667+00:00

    Open a command prompt with "run as administrator". Search for a file named set-executionpolicy. If you find one, delete it. (Or rename it if you want to be extra safe.)

    dir c:\users\set-executionpolicy /b /s
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.