There are multiple ways to execute a script in PowerShell. You can directly execute a PowerShell script in PowerShell terminal or command prompt. If you are using PowerShell core, then you can even execute a PowerShell script in your Linux terminal. You need to have proper execution policy set in order to execute the PowerShell script. Below is a quick reference –
Check current execution policy and set execution policy accordingly.
## Get the current execution policy
## Set execution policy to ByPass
Set-ExecutionPolicy ByPass -Scope CurrentUser
## Or you can even set execution policy for a specific script
powershell -ExecutionPolicy Bypass -File script.ps1
Execute PowerShell script from PowerShell terminal