Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remote exe execution through powershell script - not working as expected

Status
Not open for further replies.

Prabhasb

Programmer
Jul 1, 2018
1
0
0
US

hi

I have a exe file on remote computer which opens a browser and run some test cases when i run it. Now, When i try to run the same exe file remotely through powershell script it is not working as expected and giving some wrong output. If i login to remote computer manually and run the exe file it is working as expected.

i need to open a new remote session then open a new command prompt and then run the exe, how can achieve it through PowerShell script. Below is the script i have written


$Username = 'MYDomain\Prabha-K'
$Password = 'pas@123'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Invoke-command -ScriptBlock { & 'C:\nxtdr\SmokeTest.exe' -something "AllTestCases"} -Credential $cred -Verbose -ComputerName test01.MYDomain.com
 
Prabhasb, does this work for you?

Code:
$Username = 'MYDomain\Prabha-K'
$Password = 'pas@123'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
$server = "test01.MYDomain.com"
$session_name = "TEST01"

$remote_session = New-PSSession -Name $session_name -ComputerName $server -Credential $Cred -WarningAction silentlyContinue
Invoke-Command -Session $remote_session -ScriptBlock { & 'C:\nxtdr\SmokeTest.exe' -something "AllTestCases"}

#Clean up
Remove-PSSession $remote_session


Light travels faster than sound. That's why some people appear bright until you hear them speak.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top