The default settings of Windows disable the PowerShell script execution. This protects your computer in case a malicious PowerShell script would try to make changes on your machine. The same settings prevent you from executing your own automation scripts too.
When we try to execute a PowerShell script we get the error message
File ….ps1 cannot be loaded because running scripts
is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
To enable PowerShell script execution
in Windows 10
- Click the Windows button and type powershell into the text box,
- Right-click the Windows PowerShell item and select Run as administrator,
- In the User Account Control window click the Yes button,
- In the PowerShell window execute
Set-ExecutionPolicy unrestricted
- Press Y and the Enter key to enable the PowerShell script execution.
in Windows 7
- Click the Windows button and type powershell into the text box,
- Right-click the Windows PowerShell item and select Run as administrator,
- In the User Account Control window click the Yes button,
- In the PowerShell window execute
Set-ExecutionPolicy unrestricted