If you pass it to 'Wait-Job', prompt rather waits until the job done.
#-ScriptBlock to specify command/script to run
#-Name to specify friendly name of the job
> Start-Job -ScriptBlock { systeminfo.exe } -Name JobSysInfo
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 JobSysInfo BackgroundJob Completed True localhost systeminfo.exe
# Get Detailed property list
> (Get-Job -id 1) | Format-List -Property *
State : Completed
HasMoreData : False
StatusMessage :
Location : localhost
Command : systeminfo.exe
JobStateInfo : Completed
Finished : System.Threading.ManualResetEvent
InstanceId : 57241598-0879-41eb-93c6-58e65f4b09e2
Id : 1
Name : JobSysInfo
ChildJobs : {Job2}
PSBeginTime : 2019/05/14 12:01:20
PSEndTime : 2019/05/14 12:01:24
PSJobTypeName : BackgroundJob
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
Information : {}
#Job result can be shown by Receive-Job cmdlet
> Receive-Job (Get-Job -id 1) ホスト名: DESKTOP-0TV9VQT
OS 名: Microsoft Windows 10 Home
OS バージョン: 10.0.17134 N/A ビルド 17134
OS 製造元: Microsoft Corporation
OS 構成: スタンドアロン ワークステーション
#Long running job can be stopped by StopJob method.
> (Get-Job -id 1).StopJob()
#-Name to specify friendly name of the job
> Start-Job -ScriptBlock { systeminfo.exe } -Name JobSysInfo
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 JobSysInfo BackgroundJob Completed True localhost systeminfo.exe
# Get Detailed property list
> (Get-Job -id 1) | Format-List -Property *
State : Completed
HasMoreData : False
StatusMessage :
Location : localhost
Command : systeminfo.exe
JobStateInfo : Completed
Finished : System.Threading.ManualResetEvent
InstanceId : 57241598-0879-41eb-93c6-58e65f4b09e2
Id : 1
Name : JobSysInfo
ChildJobs : {Job2}
PSBeginTime : 2019/05/14 12:01:20
PSEndTime : 2019/05/14 12:01:24
PSJobTypeName : BackgroundJob
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
Information : {}
#Job result can be shown by Receive-Job cmdlet
> Receive-Job (Get-Job -id 1) ホスト名: DESKTOP-0TV9VQT
OS 名: Microsoft Windows 10 Home
OS バージョン: 10.0.17134 N/A ビルド 17134
OS 製造元: Microsoft Corporation
OS 構成: スタンドアロン ワークステーション
#Long running job can be stopped by StopJob method.
> (Get-Job -id 1).StopJob()
No comments:
Post a Comment