# running a PS script with psexec remotely

**URL:** <https://forums.powershell.org/t/running-a-ps-script-with-psexec-remotely/916>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/running-a-ps-script-with-psexec-remotely/916 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/running-a-ps-script-with-psexec-remotely/916/1 "2011-12-31T18:30:00Z")

</div>

by willbs at 2013-04-29 11:46:21

> i’m trying to run a powershell script remotely with psexec using this command  
>   
> psexec -i -s -d \$global:uutName -u msunet2k$global:PSexecUserName -p $global:password powershell\_ise.exe "C:\serverfolders\users\pooltest.ps1"  
>   
> powershell starts, loads the script but does not execute it  
>   
> how do i get it to execute?  
>   
> thanks

by ArtB0514 at 2013-04-29 12:08:50

> Does the same thing happen when you use powershell.exe instead of the ISE?

by willbs at 2013-04-29 12:46:10

> it starts but i get an error from the running the script  
>   
> if i run the script with powershell\_ise manually it works fine

by colt.45 at 2013-04-29 13:50:59

> What is the executionpolicy set as on the machine you are trying to execute the script on?

by willbs at 2013-04-29 14:26:54

> set-executionpolicy -scope CurrentUser -executionPolicy Unrestricted -force

by willbs at 2013-04-30 14:03:10

> what i ended up doing is running this command, and it worked fine, i didn’t need to use psexec  
>   
> # create a storage pool with 2 drives  
> invoke-command -scriptblock {  
> Invoke-Expression -command C:\serverfolders\users\CreatePool.ps1  
> } -computername $global:uutName -credential $global:Credential

---

<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:58pm UTC](https://forums.powershell.org/t/running-a-ps-script-with-psexec-remotely/916/2 "2024-05-16T20:58:21Z")

</div>


