Execution Policy error

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 3 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
VivekK
Posts: 1
Last visit: Tue Sep 08, 2020 8:22 pm

Execution Policy error

Post by VivekK »

I was just trying to Power Studio and was writing simple get-addomaincontroller BUT when I ran it, it gave me error for execution policies.

I set execution policy as unristricted in form load and on button as well, but failed.

Anyone has any idea on this ?

NOTE: I dont want to set execution policy on system first and then run the program, that will beat the purpose, I would like the execution policies to either remain same or reverted back once the program deployed, written by this app, is used.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Execution Policy error

Post by jvierra »

You cannot override domain execution policy. You cannot change execution policy in a script.

Run "Get-ExecutionPolicy -List" at a PS prompt to discover the settings.
User avatar
Alexander Riedel
Posts: 8489
Last visit: Thu Apr 18, 2024 1:15 pm
Answers: 20
Been upvoted: 37 times

Re: Execution Policy error

Post by Alexander Riedel »

Try packaging the script as an executable.
You don't say which PowerShell version you are using, so ....
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 3 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked