Invoke-Command in a background job

前端 未结 4 1351
庸人自扰
庸人自扰 2021-01-20 14:58

I have a powershell 2.0 script which should run a command on several servers and process the output. I want to run the command and the processing for each server in a backgr

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-20 15:39

    For Latest version of PS you can create a New Session and use it with Invoke-Command start-job cmdlets instead of using the ComputerName arguments directly.

    $s = new-pssession -computername Server01
    invoke-command -session $s -scriptblock { start-job -scriptblock {get-eventlog system}}
    

提交回复
热议问题