Get-Job (Microsoft.PowerShell.Core) - PowerShell | Microsoft Learn
Tue Jul 09 2024 01:34:38 GMT+0000 (Coordinated Universal Time)
Saved by
@Dewaldt
Start-Job -ScriptBlock {Get-EventLog -LogName System}
Invoke-Command -ComputerName S1 -ScriptBlock {Get-EventLog -LogName System} -AsJob
Invoke-Command -ComputerName S2 -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog -LogName System}}
Get-Job
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 Job1 BackgroundJob Running True localhost Get-EventLog System
2 Job2 RemoteJob Running True S1 Get-EventLog System
$Session = New-PSSession -ComputerName S2
Invoke-Command -Session $Session -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog -LogName System}}
Invoke-Command -Session $Session -ScriptBlock {Get-Job}
Id Name PSJobTypeName State HasMoreData Location Command PSComputerName
-- ---- ------------- ----- ----------- -------- ------- --------------
1 Job1 BackgroundJob Running True localhost Get-EventLog -LogName Sy… S2
content_copyCOPY
https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view
Comments