This error may occur because the Windows PowerShell execution policy is set to prevent untrusted scripts from affecting your Windows client environment. The default execution policy is “strict” on client operating systems like Windows 10/11 PC, preventing Windows PowerShell commands and scripts from running.
Open the PowerShell Console by selecting “Run as Administrator” (Or Right-click the Start menu and choose “Windows PowerShell (Admin)” from the context menu) and get the execution Policy with the command:
Get-ExecutionPolicy
This will get the current script execution policy applied, such as “Restricted” which means PowerShell scripts are disabled.
Set the execution Policy with the following command:
Set-ExecutionPolicy RemoteSigned
You’ll see a security risk warning. Type “Y” or “A” when prompted to proceed.
Now run try to run your script.