Script is not executed because an errormessage is displayed.
This is the default setting to enhance security on Windows 10 and 11.
To run the script, you will have to change the execution policy of powershell scripts.
This can be done with the Set-ExecutionPolicy command.
To be able to execute all scripts, you can use:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Most of the time the following command will do:
Set-ExecutionPolicy -ExecutionPolicy Remote
Remote is the same as RemoteSigned. The execution policy type can be one of the following:
- Restricted (default)
You can also enter a scope, which is LocalMachine by default. Other scopes are:
- LocalMachine (default)
You will have to answer the question with "yes" but afterwards your script can be executed.
To just temporarily execute a script you can use a kind of bypass for the policy by doing this:
powershell -ExecutionPolicy ByPass -File your_script.ps1
This can also be used for running scripts in workspace ONE UEM.
Disclaimer:The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!
About the Author
Author: Wim Peeters - Keskon GmbH & Co. KG
Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.
Latest update: 01.06.2022 | Comment: