# Trying to run Powershell Advance Function on a List of machines.

**URL:** <https://forums.powershell.org/t/trying-to-run-powershell-advance-function-on-a-list-of-machines/15527>\
**Category:** PowerShell Help\
**Created:** [January 26, 2021, 3:38am UTC](https://forums.powershell.org/t/trying-to-run-powershell-advance-function-on-a-list-of-machines/15527 "2021-01-26T03:38:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![othompson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/othompson/32/16_2.png) [@othompson](https://forums.powershell.org/u/othompson)\
**Post date:** [January 26, 2021, 3:38am UTC](https://forums.powershell.org/t/trying-to-run-powershell-advance-function-on-a-list-of-machines/15527/1 "2021-01-26T03:38:16Z")

</div>

I have a Powershell script/function that works when you run in locally on one device. I have a need to run it on multiple devices from a csv or txt file. How can I do that? It is a pretty complexed script with over 3500 lines in it so I need to ensure that everything in the script gets executed on each of the devices in the list. I am happy to share the script if that would be helpful.

Any insight or examples of how this could be accomplished is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![ralphmwr](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/ralphmwr/32/1064_2.png) [@ralphmwr](https://forums.powershell.org/u/ralphmwr)\
**Post date:** [January 26, 2021, 4:04am UTC](https://forums.powershell.org/t/trying-to-run-powershell-advance-function-on-a-list-of-machines/15527/2 "2021-01-26T04:04:24Z")

</div>

I would recommend Invoke-Command. PS has great documentation on it Get-Help [Invoke-Command](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-5.1) You can use it to run an entire script on multiple remote computers. For example:

```
$computerlist = Get-Content "C:\lists.txt"

Invoke-Command -ComputerName $computerlist -FilePath "C:\myscript.ps1"
```

By default any objects returned from Invoke-Command will include a PSComputerName property which will by the computername of the remote machine it came from. This is necessary because the script will be running simultaneously on machines you pass to the ComputerName parameter. In my example $computerlist.

Anyway, that is where I would start. Good luck and post back if you need any further 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:27pm UTC](https://forums.powershell.org/t/trying-to-run-powershell-advance-function-on-a-list-of-machines/15527/3 "2024-05-16T20:27:58Z")

</div>


