# Running a server based powershell script from a pc

**URL:** <https://forums.powershell.org/t/running-a-server-based-powershell-script-from-a-pc/21169>\
**Category:** PowerShell Help\
**Created:** [December 15, 2022, 11:40am UTC](https://forums.powershell.org/t/running-a-server-based-powershell-script-from-a-pc/21169 "2022-12-15T11:40:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roo](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Roo](https://forums.powershell.org/u/Roo)\
**Post date:** [December 15, 2022, 11:40am UTC](https://forums.powershell.org/t/running-a-server-based-powershell-script-from-a-pc/21169/1 "2022-12-15T11:40:16Z")

</div>

Hi,  
I’ve created a powershell script that runs a couple of server based programs. It is normally a scheduled process but I am now asked to provide a “normal” user to run the process. The PS1 needs to be on the server as the software it integrates with only resides on it.

I’ve done some searching but can’t seem to get my head around the best method. Ideally I would want the user to click a button on a internal webpage, or double click a shared executable. and for that to trigger the PS script to execute on the server (not on the clients PC)

any help would be greatly appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![Roo](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Roo](https://forums.powershell.org/u/Roo)\
**Post date:** [December 15, 2022, 12:22pm UTC](https://forums.powershell.org/t/running-a-server-based-powershell-script-from-a-pc/21169/2 "2022-12-15T12:22:41Z")

</div>

Just to be clear I’ve used the invoke-command -server… option on the client PC it works up to the point where the script opens another program

In the first instance it invoke a SQL query and exports it to a file. It won’t get past this

---

<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:** [December 15, 2022, 1:33pm UTC](https://forums.powershell.org/t/running-a-server-based-powershell-script-from-a-pc/21169/3 "2022-12-15T13:33:48Z")

</div>

Roo,  
Welcome to the forum. 👋🏽

> [@Roo](#):
>
> It is normally a scheduled process but I am now asked to provide a “normal” user to run the process. The PS1 needs to be on the server as the software it integrates with only resides on it.

So you actually don’t want this script to be run by another user - you want another user to trigger the scheduled task, right? 😉

If that’s the case you may use

> **[Schtasks.exe - Win32 apps](https://learn.microsoft.com/en-us/windows/win32/taskschd/schtasks)**
>
> Enables an administrator to create, delete, query, change, run, and end scheduled tasks on a local or remote computer.

to trigger the task on the server.

> [@Roo](#):
>
> invoke-command -server…

Just to precise - `Invorke-Command` does not have a parameter `-Server` !! 😉

---

<div class="post-metadata">

**Author:** ![Roo](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Roo](https://forums.powershell.org/u/Roo)\
**Post date:** [December 15, 2022, 1:38pm UTC](https://forums.powershell.org/t/running-a-server-based-powershell-script-from-a-pc/21169/4 "2022-12-15T13:38:32Z")

</div>

Thanks for your reply and welcome

1. So I can allow the user to trigger a scheduled task remotely? I’ll look that up

2. I just removed the rest of the script 😃 - it did work… up to opening the sql part.

---

<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:** [December 15, 2022, 1:51pm UTC](https://forums.powershell.org/t/running-a-server-based-powershell-script-from-a-pc/21169/5 "2022-12-15T13:51:57Z")

</div>

> [@Roo](#):
>
> So I can allow the user to trigger a scheduled task remotely? I’ll look that up

Just click on the link I posted … it’s the documentation?! 🤷🏽‍♂️

> [@Roo](#):
>
> I just removed the rest of the script 😃 - it did work… up to opening the sql part.

I didn’t get that. And it does not make that much sense to talk about a script if we don’t see the actual code. 🤷🏽‍♂️

---

<div class="post-metadata">

**Author:** ![Roo](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Roo](https://forums.powershell.org/u/Roo)\
**Post date:** [December 15, 2022, 3:56pm UTC](https://forums.powershell.org/t/running-a-server-based-powershell-script-from-a-pc/21169/6 "2022-12-15T15:56:09Z")

</div>

Perfect - Works a treat - thanks for the heads up 😃

---

<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/running-a-server-based-powershell-script-from-a-pc/21169/7 "2024-05-16T20:16:15Z")

</div>


