Link to home
Start Free TrialLog in
Avatar of IT Guy
IT GuyFlag for United States of America

asked on

Process and correct syntax for using psexec to run PowerShell script on remote servers

I have a PowerShell script named PSInstallAgent.ps1  that I need to run on several remote servers.


The contents of the PSInstallAgent.ps1  PowerShell script are contained at this URL.


I'm hoping to be able to do this with the PSExec Sysinternals PowerToy. The homepage for this utility is here.


So what is the process and the correct syntax for using psexec to run this PSInstallAgent.ps1  PowerShell script on remote servers?


One note about this PSInstallAgent.ps1  PowerShell script is that I have only been able to get it to execute correctly using group policy when it has been set to run during system startup.


This system startup location within group policy is found within the  Computer Configuration\Policies\Windows Settings\Scripts (Startup/Shutdown)\PowerShell Scripts location: 

User generated image


Avatar of Seth Simmons
Seth Simmons
Flag of United States of America image

you need to download it first

https://docs.microsoft.com/en-us/sysinternals/downloads/psexec

then you run from the command line; something like...

psexec \\server1,server2,server3 -s powershell

Open in new window


...then finish the command line
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IT Guy

ASKER

Does psexec require that drive letters be used or can it use UNC paths for running the PowerShell command from a server share?

I'm hoping I can use UNC paths as described in my other questions.

The command I need to run as part of psexec that will run this command on the remote servers to install the Manage Engine agent on the remote servers will be something like the following:

Is this something that psexec will be able to run?

powershell.exe\\domain.com\SysVol\domain.com\Policies\{257C7763-BE37-42F0-B232-A3875D7D01B5}\Machine\Scripts\Startup\PSInstallAgent.ps1 "DesktopCentralAgent.msi" "DesktopCentralAgent.mst" "DMRootCA.crt" "DMRootCA-Server.crt"

Open in new window

Avatar of IT Guy

ASKER

Also is psexec able to read from a CSV file that contains the names of the remote servers where this command needs to be run?

What will be the command line syntax for using psexec to run and then execute the command shown above to run this command on the remote servers by getting the computer names of these remote servers from a CSV file?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IT Guy

ASKER

Unfortunately using psexec hasn't been successful since the cheap Sophos antivirus software running on our servers detects when psexec is being used and blocks it thinking that it is an attack.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IT Guy

ASKER

footech,

Can you provide me with more detailed steps on using PowerShell remoting?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial