The AsJob parameter

The AsJob parameter can be used with Invoke-Command, for example:

$session = New-PSSession PSTest 
Invoke-Command -Session $session -AsJob -ScriptBlock { Start-Sleep -Seconds 120 'Done sleeping' } 

The command finishes immediately, and returns the job that has been created.

While the job is running, the session availability is set to Busy:

PS> $session | Select-Object Name, ComputerName, Availability

Name ComputerName Availability
---- ------------ ------------
Session1 PSTest Busy

Attempts to run another command against the same session will result in an error message.

Once the job has completed, the Receive-Job command may be used.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.185.155