Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Poowershell execute a job in the background

$
0
0

I am trying to execute a powershell command in  my local computer using the below command. I log in to powershell and then execute the below command to execute a cmd script in the background , in my local computer. It works.

invoke-command -computername mycomputername -scriptblock{ C:\Data\test.cmd} -AsJob

Now if don't login in to powershell but from my normal command prompt if i execute the same command by passing the invoke command as a parameter to the powershell.exe, the script is not executed.

c:\Users\myusername>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe 

invoke-command -computername mycomputername -scriptblock{ C:\Data\test.cmd} -AsJob

If i remove the -AsJob from the above command, then i am able to execute the script. Can i not use the above command to execute a script in background by passing it as a parameter to the powershell.exe process. I need this because in my external application i have to call powershell using theC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe  command.Am I missing anything? Any help is appreciated.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>