# Launching Powershell from

**URL:** <https://forum.inductiveautomation.com/t/launching-powershell-from/83945>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 8, 2024, 8:36pm UTC](https://forum.inductiveautomation.com/t/launching-powershell-from/83945 "2024-01-08T20:36:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Siebold](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/siebold/32/47336_2.png) [@Siebold](https://forum.inductiveautomation.com/u/Siebold)\
**Post date:** [January 8, 2024, 8:36pm UTC](https://forum.inductiveautomation.com/t/launching-powershell-from/83945/1 "2024-01-08T20:36:16Z")

</div>

I am trying to run a powershell script that lives on my gateway from a perspective session. Currently the script just writes out to a txt file to see if it will work but I can't get it to fire. I am trying the method shown [here](https://forum.inductiveautomation.com/t/powershell-script/73793/8).

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 8, 2024, 9:00pm UTC](https://forum.inductiveautomation.com/t/launching-powershell-from/83945/2 "2024-01-08T21:00:19Z")

</div>

Show your code. Use the preformatted text button to make it readable.

---

<div class="post-metadata">

**Author:** ![Siebold](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/siebold/32/47336_2.png) [@Siebold](https://forum.inductiveautomation.com/u/Siebold)\
**Post date:** [January 8, 2024, 9:09pm UTC](https://forum.inductiveautomation.com/t/launching-powershell-from/83945/3 "2024-01-08T21:09:17Z")

</div>

Script in Ignition

```auto
def testRun():
    system.util.execute(["powershell.exe","-File","C:\\ssh\\autoScript.py1"])

```

autoScript.py1 on gateway computer

```auto
$curTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$filePath = "C:\ssh\log.txt"
$curTime | Out-File -Append -FilePath $filePath

```

Running the powershell when remoted into the gateway works.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 8, 2024, 9:10pm UTC](https://forum.inductiveautomation.com/t/launching-powershell-from/83945/4 "2024-01-08T21:10:56Z")

</div>

Does the gateway service's user account have access to the `C:\ssh\` folder?

---

<div class="post-metadata">

**Author:** ![Siebold](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/siebold/32/47336_2.png) [@Siebold](https://forum.inductiveautomation.com/u/Siebold)\
**Post date:** [January 8, 2024, 9:17pm UTC](https://forum.inductiveautomation.com/t/launching-powershell-from/83945/5 "2024-01-08T21:17:44Z")

</div>

I believe so

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/3/e326feb7ce6c620d3d5894ba4ac5ae748d717d93.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/053f10db1c2f1c025d3c80c8086285ad7cc96c5d.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 8, 2024, 9:30pm UTC](https://forum.inductiveautomation.com/t/launching-powershell-from/83945/6 "2024-01-08T21:30:33Z")

</div>

Hmmm. Maybe the `PATH` is different. Try spelling out the path to `powershell.exe`.

---

<div class="post-metadata">

**Author:** ![Siebold](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/siebold/32/47336_2.png) [@Siebold](https://forum.inductiveautomation.com/u/Siebold)\
**Post date:** [January 8, 2024, 10:04pm UTC](https://forum.inductiveautomation.com/t/launching-powershell-from/83945/7 "2024-01-08T22:04:49Z")

</div>

I tried a couple different things like including the whole path, removing the .exe, adding `-ExecutionPolicy Bypass` but none of it worked.
