This topic contains 10 replies, has 3 voices, and was last updated by
November 18, 2015 at 4:42 am #32065
powershell.exe -? says there is a parameter ExecutionPolicy
when I try to run
c:\ > powershell.exe -executionPolicy Unrestricted -command "Get-ExecutionPolicy"
November 18, 2015 at 4:49 am #32066
you can run it like this to get the expected output:
powershell.exe -executionPolicy Unrestricted -command "Get-ExecutionPolicy -Scope Process"
I hope this helps.
November 18, 2015 at 4:51 am #32067
but i still cannot run remote scripts..
November 18, 2015 at 4:54 am #32068
You specify the script path with -File parameter?
November 18, 2015 at 4:55 am #32069
November 18, 2015 at 5:02 am #32070
That is odd,
I've just downloaded a script from Script Center to try it on my machine and it works as expected.
My execution policy is RemoveSigned so i cannot run it in normal powershell window, but it works if i run it like this
powershell.exe -executionPolicy Unrestricted -command "Get-ExecutionPolicy -Scope Process" -File "C:\Users\\Desktop\ActiveSyncReport.ps1"
forget all i worte before. it doesnt work here too.
November 18, 2015 at 5:10 am #32072
you are trying to run _local_ script
powershell.exe -executionPolicy Unrestricted -File "\\some\network\share\script.ps1
November 18, 2015 at 5:13 am #32073
Just edited my last post, it's not working for me too
November 18, 2015 at 5:57 am #32077
After some more digging around, i think the this is an issue of executionpolicy scope precedence, its described here:
i got a clue to this by running "Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted" and getting an the following error:
Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will
retain its current effective execution policy of RemoteSigned. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more information please see "Get-Help Set-ExecutionPolicy".
At line:1 char:1
November 18, 2015 at 6:00 am #32078MemberPoints: 0Rank: Member
Looks like you've got an execution policy being assigned by Group Policy, which is why your effective policy is still set to RemoteSigned. You can see more detail with: powershell.exe -ExecutionPolicy Bypass -Command Get-ExecutionPolicy -List
If the MachinePolicy or UserPolicy options are anything other than "Undefined", then they will take precedence over everything else in the list (including Process, which is what gets set by powershell.exe's parameter.
November 18, 2015 at 8:53 pm #32106
Noam, Dave thanks a lot
now it is clear to me
The topic ‘ExecutionPolicy parameter’ is closed to new replies.