This section provides instructions on how to execute PowerShell scripts (.ps1) on a Windows environment.
- Locate your
.ps1file in File Explorer. - Right-click the file and select Run with PowerShell.
Open PowerShell and call the script directly. Use quotes and an ampersand if your path contains spaces:
& "C:\Path\To\Your\Script.ps1"By default, Windows restricts script execution. If you encounter an error regarding "running scripts is disabled," use one of the following commands to bypass the restriction:
| Method | Command |
|---|---|
| Current Session Only | Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process |
| One-Time Run | powershell.exe -ExecutionPolicy Bypass -File "YourScript.ps1" |
Admin Rights: If the script fails due to permissions, ensure you are running PowerShell as an Administrator.
Unblocking Files: If the script was downloaded from the web, right-click the file > Properties > Check Unblock > Apply.