# Execution Policy for Script

**URL:** <https://forums.powershell.org/t/execution-policy-for-script/21266>\
**Category:** PowerShell Help\
**Created:** [January 3, 2023, 10:39am UTC](https://forums.powershell.org/t/execution-policy-for-script/21266 "2023-01-03T10:39:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![NewUser](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@NewUser](https://forums.powershell.org/u/NewUser)\
**Post date:** [January 3, 2023, 10:39am UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/1 "2023-01-03T10:39:36Z")

</div>

Is there any way to run power-shell script without passing the ‘-Bypass’ flag or changing the execution policy on a machine? Is the only other way to get it working is to get it signed?

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 3, 2023, 10:55am UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/2 "2023-01-03T10:55:35Z")

</div>

It depends on your environment. You can set the execution policy either by a policy or you can set it once by calling `Set-ExecutionPolicy` as administrator.

Is there a particular problem you try to solve?

---

<div class="post-metadata">

**Author:** ![NewUser](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@NewUser](https://forums.powershell.org/u/NewUser)\
**Post date:** [January 3, 2023, 12:28pm UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/3 "2023-01-03T12:28:51Z")

</div>

I want to run the script in production, so I cannot change the execution policy of the machine

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 3, 2023, 12:36pm UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/4 "2023-01-03T12:36:46Z")

</div>

That does not explain nothing at all.

What does that mean … in production? 🤔 Why can’t you not change the execution policy? 🤔

Are we talking about servers or clients? 🤔 About how many machines are we talking here? 🤔 Are we talking about domain joined machines or a workgroup? 🤔 How do you like to run the script? 🤔

Here you have already 6 questions and I could think about more actually. 😏

… please keep in mind … we cannot see your screen or your environment and we cannot read your mind.

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [January 3, 2023, 1:49pm UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/5 "2023-01-03T13:49:17Z")

</div>

> [@NewUser](#):
>
> I want to run the script in production, so I cannot change the execution policy of the machine

This seems backwards. Typically, you’d change the execution policy to an appropriate level to achieve the desired result (run a script.) You could make a permanent change or per invocation.

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [January 3, 2023, 11:15pm UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/6 "2023-01-03T23:15:57Z")

</div>

What is wrong with setting per invocation as Doug suggests?

---

<div class="post-metadata">

**Author:** ![NewUser](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@NewUser](https://forums.powershell.org/u/NewUser)\
**Post date:** [January 5, 2023, 5:53am UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/7 "2023-01-05T05:53:32Z")

</div>

I don’t really know who is gonna use this script, but I do know they won’t be changing the policies on their machine for running this.

I guess the option remaining is to get the script signed.

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [January 5, 2023, 7:37am UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/8 "2023-01-05T07:37:42Z")

</div>

No the end user would not be changing the policy. The administrator of the machine that accepts/desires the script being ran would. Either that or the script would be ran with the execution policy set for just that invocation, like so.

```auto
Powershell.exe -ExecutionPolicy bypass -File path\to\script.ps1

```

You could call that with a batch file, a shortcut, or even a vbscript.

Getting the scripts signed may work depending if you sign it with a public cert or not. If you don’t then you’d need to configure the systems to trust the cert first. Which seems to be what your trying to avoid. Also keep in mind if the script is downloaded or copied it may need to be “unblocked” (through explorer or Unblock-File)

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 5, 2023, 10:55am UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/9 "2023-01-05T10:55:59Z")

</div>

> [@NewUser](#):
>
> I don’t really know who is gonna use this script, but I do know they won’t be changing the policies on their machine for running this.

You could start with answering some of the questions I asked. Then we might be able to help you better. 😉

---

<div class="post-metadata">

**Author:** ![NewUser](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@NewUser](https://forums.powershell.org/u/NewUser)\
**Post date:** [January 6, 2023, 10:59am UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/10 "2023-01-06T10:59:39Z")

</div>

Finally got to know that I need not worry about execution policies, the guys running the script would be handling that.

Thank you guys for all the help!

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:16pm UTC](https://forums.powershell.org/t/execution-policy-for-script/21266/11 "2024-05-16T20:16:06Z")

</div>

Closed on May 16, 2024, 8:16pm UTC


