1
00:00:00,140 --> 00:00:02,310
So let's understand the PowerShell job

2
00:00:02,310 --> 00:00:06,280
flow. Well first off, we start the

3
00:00:06,280 --> 00:00:09,650
PowerShell job. Then we can retrieve the

4
00:00:09,650 --> 00:00:12,600
job, so get the information about the job,

5
00:00:12,600 --> 00:00:15,350
the current status, etc. We'll then need

6
00:00:15,350 --> 00:00:18,070
to wait for the job to execute its

7
00:00:18,070 --> 00:00:20,520
commands. And then we can retrieve the

8
00:00:20,520 --> 00:00:23,370
results from whatever we passed into that

9
00:00:23,370 --> 00:00:25,420
job, whether it was a PS script that we

10
00:00:25,420 --> 00:00:28,050
passed or we just had it execute another

11
00:00:28,050 --> 00:00:30,020
command. And then, of course, we can

12
00:00:30,020 --> 00:00:32,380
remove the job. And that's the process

13
00:00:32,380 --> 00:00:33,840
flow that we should go through when

14
00:00:33,840 --> 00:00:36,220
utilizing background jobs. We start the

15
00:00:36,220 --> 00:00:39,650
job, wait, retrieve, receive, etc., and

16
00:00:39,650 --> 00:00:42,030
then clear the job up. It's important to

17
00:00:42,030 --> 00:00:44,200
understand that we do remove jobs at the

18
00:00:44,200 --> 00:00:46,670
end so they don't just sit in the batch

19
00:00:46,670 --> 00:00:49,880
queue and be listed there. So that process

20
00:00:49,880 --> 00:00:53,120
flow has specific PowerShell cmdlets that

21
00:00:53,120 --> 00:00:56,770
are tied to each object. So to initiate

22
00:00:56,770 --> 00:01:00,190
the job, we use Start‑Job. To get the

23
00:01:00,190 --> 00:01:02,020
current status of the job, we can use

24
00:01:02,020 --> 00:01:05,840
Get‑Job. To wait for the job, we can use

25
00:01:05,840 --> 00:01:09,780
Wait‑Job. To retrieve the results for the

26
00:01:09,780 --> 00:01:16,000
job, we use Receive‑Job. And then to clear that job down, we use Remove‑Job.

