The AsJob parameter

The AsJob command can be used with Invoke-Command. For example:

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

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

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

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
3.145.9.148