1
00:00:00,570 --> 00:00:04,540
So why should we use PowerShell jobs?

2
00:00:04,540 --> 00:00:07,060
Well, the PowerShell background jobs allow

3
00:00:07,060 --> 00:00:10,980
you to move singular tasks into batches of

4
00:00:10,980 --> 00:00:13,930
tasks for easier management. This allows

5
00:00:13,930 --> 00:00:16,400
us to increase performance because jobs

6
00:00:16,400 --> 00:00:18,760
execute separately, allowing for better

7
00:00:18,760 --> 00:00:21,590
performance. We can execute multiple

8
00:00:21,590 --> 00:00:23,780
tasks, which means it's not going to lock

9
00:00:23,780 --> 00:00:26,270
the PowerShell console while the tasks are

10
00:00:26,270 --> 00:00:28,830
being executed, and we could also schedule

11
00:00:28,830 --> 00:00:34,140
the tasks also to run at specific times.

12
00:00:34,140 --> 00:00:36,680
We can also use this for long running

13
00:00:36,680 --> 00:00:38,990
tasks. So for example, maybe you want to

14
00:00:38,990 --> 00:00:42,650
execute something that's going to query a

15
00:00:42,650 --> 00:00:45,910
database or some other set of files and

16
00:00:45,910 --> 00:00:47,810
there's a lot of them, you can use a

17
00:00:47,810 --> 00:00:50,500
PowerShell job for that long running task.

18
00:00:50,500 --> 00:00:53,870
We can also use them for remoting. So, for

19
00:00:53,870 --> 00:00:56,850
example, if I wanted to use a PowerShell

20
00:00:56,850 --> 00:00:59,610
job that did something on multiple servers

21
00:00:59,610 --> 00:01:02,170
in my estate, then I can use PowerShell

22
00:01:02,170 --> 00:01:04,910
remoting tasks inside a background job for

23
00:01:04,910 --> 00:01:08,140
that one. An important thing to understand

24
00:01:08,140 --> 00:01:11,280
is that scheduled jobs, or what used to be

25
00:01:11,280 --> 00:01:13,220
available within previous versions of

26
00:01:13,220 --> 00:01:15,240
PowerShell, are not supported within

27
00:01:15,240 --> 00:01:19,600
PowerShell 7. You can still create tasks

28
00:01:19,600 --> 00:01:21,790
that will execute these commands, but the

29
00:01:21,790 --> 00:01:23,440
old way of doing it is no longer

30
00:01:23,440 --> 00:01:27,160
supported. Now let's talk about some kind

31
00:01:27,160 --> 00:01:29,620
of scenarios. So why would you use

32
00:01:29,620 --> 00:01:32,090
PowerShell jobs? Well, for example, you

33
00:01:32,090 --> 00:01:34,040
might be in a large organization where

34
00:01:34,040 --> 00:01:36,150
there are hundreds of servers to manage

35
00:01:36,150 --> 00:01:38,620
and maybe you need to query all of them

36
00:01:38,620 --> 00:01:42,600
for the amount of RAM on the servers. A

37
00:01:42,600 --> 00:01:44,650
second option could be maybe you're using

38
00:01:44,650 --> 00:01:48,200
on‑premises and cloud services, and maybe

39
00:01:48,200 --> 00:01:51,160
you need to update specific details within

40
00:01:51,160 --> 00:01:53,830
Azure Active Directory from another

41
00:01:53,830 --> 00:01:57,050
on‑premises application. So both instances

42
00:01:57,050 --> 00:01:59,860
are kind of long running jobs that are

43
00:01:59,860 --> 00:02:04,020
suited very well to a background job, so

44
00:02:04,020 --> 00:02:06,340
we can kick those off and just leave them

45
00:02:06,340 --> 00:02:09,000
to it, and they will complete when they are ready.

