×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

remote exe execution through powershell script - not working as expected

remote exe execution through powershell script - not working as expected

remote exe execution through powershell script - not working as expected

(OP)

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

RE: remote exe execution through powershell script - not working as expected

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close