# Execute a batch file on a remote server

**URL:** <https://forums.powershell.org/t/execute-a-batch-file-on-a-remote-server/4083>\
**Category:** PowerShell Help\
**Created:** [April 22, 2015, 1:59am UTC](https://forums.powershell.org/t/execute-a-batch-file-on-a-remote-server/4083 "2015-04-22T01:59:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![byeron89](https://avatars.discourse-cdn.com/v4/letter/b/ee7513/32.png) [@byeron89](https://forums.powershell.org/u/byeron89)\
**Post date:** [April 22, 2015, 1:59am UTC](https://forums.powershell.org/t/execute-a-batch-file-on-a-remote-server/4083/1 "2015-04-22T01:59:39Z")

</div>

Just looking for some tips on writing a script to execute a batch file on a remote server. I don’t to use the PsExec tool as I want users to be able to run the script easily.  
I read on a technet forum that you create a process using an object to execute the batch file.

Thanks!

---

<div class="post-metadata">

**Author:** ![daniel-krebs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/daniel-krebs/32/484_2.png) [@daniel-krebs](https://forums.powershell.org/u/daniel-krebs)\
**Post date:** [April 22, 2015, 2:03am UTC](https://forums.powershell.org/t/execute-a-batch-file-on-a-remote-server/4083/2 "2015-04-22T02:03:23Z")

</div>

Hi Byron,

Please check out the Invoke-Command cmdlet to run scripts on one or more remote servers.

```
Get-Help Invoke-Command
Get-Help Invoke-Command -Examples
```

[https://technet.microsoft.com/en-us/library/hh849719.aspx](https://technet.microsoft.com/en-us/library/hh849719.aspx)

```
Invoke-Command -ComputerName MyRemoteServer -ScriptBlock { $env:COMPUTERNAME }
```

Best,  
Daniel

---

<div class="post-metadata">

**Author:** ![byeron89](https://avatars.discourse-cdn.com/v4/letter/b/ee7513/32.png) [@byeron89](https://forums.powershell.org/u/byeron89)\
**Post date:** [April 23, 2015, 6:45pm UTC](https://forums.powershell.org/t/execute-a-batch-file-on-a-remote-server/4083/3 "2015-04-23T18:45:08Z")

</div>

Hi Daniel

Will check out the cmdlet!

Thanks!

---

<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:45pm UTC](https://forums.powershell.org/t/execute-a-batch-file-on-a-remote-server/4083/4 "2024-05-16T20:45:24Z")

</div>


