Quick question, have searched for awhile but can't find answer anywhere. Some background: I have a local machine and remote machine (Virtual Machine) that I am connecting through RDP.

I have a batch file that I run that starts the RDP session through powershell commands and logs in with credentials. My next step is where I run into problems, I have another batch file on the remote machine that I want to run (also Powershell commands).

When I run this batch file physically through the RDP (by either double clicking or running through command prompt) all is well.

When I trigger the batch file remotely the batch file runs, but not the way I want. It seems like it runs in the background and not actually showing what its doing through the RDP session I have. The reason I don't want this running in silent mode is because I have a script that uninstalls and re installs a program. Since it is not MSI I have to have several "Send Keys" in my code.

So in the end my question is this, can I run a batch file remotely that will act as if I double clicked the batch file on the remote machine??? I believe that there is an option psexec, but I would prefer not to use any more programs than needed.

  • ok seems like this is a limitation of powershell and not of the batch file im running. The ps1 files allow for a non-interactive session to be created. Anyone have a workaround? – kal Jan 14 '15 at 22:18
  • Did you manage to solve this yet? I have just come across the same issue and trying to find a fix. My batch file triggers a load of python scripts and doesn't work if i trigger it remotely but it did correctly if i RDP manually and double click the batch file. – Will Webb May 18 '16 at 15:32

Have you tried Enter-PSSession?

$s = New-PSSession -ComputerName Server01 -Credential Domain01\User01 
# Enter the session yourself
Enter-PSSession -Session $s


Invoke-Command -Session $s -ScriptBlock {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.