0

Powershell + psExec

image_pdfimage_print

Launching Powershell Remotely via psExec

From Powershell: Launch Powershell Remotely via psExec

driveletter:\somepath\psexec.exe \\hostname cmd /c 'echo . | powershell.exe -command "$env:PROCESSOR_ARCHITECTURE; exit 100"'

From CMD: Launch Powershell Remotely via psExec

powershell.exe -command "& {driveletter:\somepath\psexec\psexec.exe \\hostname cmd /c 'echo . | powershell.exe -command "$env:PROCESSOR_ARCHITECTURE; exit 100"'}"

Case Use:
Remotely Stop an IIS Application Pool

powershell.exe -command "& {driveletter:\somepath\psexec.exe \\hostname cmd /c 'echo . | powershell.exe -command "set-executionpolicy Bypass -scope Process;Import-Module WebAdministration;Stop-WebAppPool -Name "MyAppPool"; exit 100"'}" 

Bert Tejeda

Leave a Reply

Your email address will not be published. Required fields are marked *

Protected with IP Blacklist CloudIP Blacklist Cloud