We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
8
199
Set-ExecutionPolicy Restricted seems to be the way to undo it if you want to put the permissions back to as they were: technet.microsoft.com/en-us/library/ee176961.aspx. The temporary bypass method by @Jack Edmonds looks safer to me: powershell -ExecutionPolicy ByPass -File script.ps1
Set-ExecutionPolicy RemoteSigned cannot be the first line in your script. If it is, highlight it and run selected only INITIALLY before running the rest of your script.
I came across a similar question on SF site, "Powershell execution policy within SQL Server" asked Oct 10 '14. The answers there included Get-ExecutionPolicy -List which helped me to see the different scopes. The cmd Get-ExecutionPolicy does not show all the scopes. Import-Module SQLPS is now working with policies changed as follows: {Undefined- Process,MachinePolicy,UserPolicy,}; {RemoteSigned- CurrentUser, LocalMachine}.
@SharpC, it is Undefined that reverts the policy in a given scope to its default; e.g., Set-ExecutionPolicy -Scope CurrentUser Undefined -Force. While on workstation editions of Windows using Restricted has the same effect, note that - at least nowadays - server editions default to RemoteSigned.
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
complete the sentence: my question is about...
use tags that describe things or concepts that are essential, not incidental to your question
Set-ExecutionPolicy Restrictedseems to be the way to undo it if you want to put the permissions back to as they were: technet.microsoft.com/en-us/library/ee176961.aspx. The temporary bypass method by@Jack Edmondslooks safer to me:powershell -ExecutionPolicy ByPass -File script.ps1Get-ExecutionPolicy -Listwhich helped me to see the different scopes. The cmdGet-ExecutionPolicydoes not show all the scopes.Import-Module SQLPSis now working with policies changed as follows:{Undefined- Process,MachinePolicy,UserPolicy,}; {RemoteSigned- CurrentUser, LocalMachine}.Undefinedthat reverts the policy in a given scope to its default; e.g.,Set-ExecutionPolicy -Scope CurrentUser Undefined -Force. While on workstation editions of Windows usingRestrictedhas the same effect, note that - at least nowadays - server editions default toRemoteSigned.