0

Edit: Ok, that's weird. Maybe I just screwed up my testing. The command that I indicated does work. What doesn't is using it within a Foreach loop within the ISE (version 4). Within a regular Powershell console, it also does work.

foreach ($computer in @("2008R2-test","anotherServer")) { Start-Job -name $computer -ScriptBlock { Invoke-Command -computerName $computer -scriptBlock {$?} } }

The job never stops running, never is "completed". I don't get the cursor back. It hangs and I have to kill the ISE with task manager to get it back. The "$?" is just an example of running anything. I'm trying to do it this way because I want to run some commands that will display stuff to the screen, then do stuff that can happen in the background including a command that runs at the remote machine. I guess it's just another case of not being able to use the ISE.

Roman
  • 344
  • 1
  • 6
  • 19
  • Have a look here: http://stackoverflow.com/questions/17696149/invoke-command-in-a-background-job – Martin Apr 28 '16 at 06:01
  • this is running your script block on a remote computer, you should not get any console output from the `invoke-command -computer xxx` line. This is expected behavior. You can have your script block print output to text file and get it back to you. – Kai Zhao Apr 29 '16 at 00:43
  • The invoke-computer command against a remote machine most defintely gives console output. And my initial understanding was wrong; so, this thread is kind of moot unless one reads the current version of the original post. – Roman May 03 '16 at 13:42

0 Answers0