I have a script which should be running on dozens computers at the first time,
so I need to Set-ExecutionPolicy Unrestricted before I run it. I’ve just added the following line at the top of the script:
On top of that, ISE development has ended. Windows PowerShell v5.1 was the last version supported in ISE, but if your system is up to date you should be using PowerShell Core v7+.
So, you need to test your script either in VSCode or in the shell itself before trying to use it in your production environment. Testing done in ISE is not valid.
Regardless of all that if you have to change the execution policy in order to run a script you can’t run a script to change the execution policy. You’ll have to change it ahead of time or call powershell executable with -executionpolicy parameter
[quote quote=273906]Regardless of all that if you have to change the execution policy in order to run a script you can’t run a script to change the execution policy. You’ll have to change it ahead of time or call powershell executable with -executionpolicy parameter
[/quote]
yes, that’s the best for me, worked great, thanks!