1
00:00:00,340 --> 00:00:01,890
[Autogenerated] So let's go back into our

2
00:00:01,890 --> 00:00:04,050
machine on. We'll look at how we execute

3
00:00:04,050 --> 00:00:07,090
jobs locally on. Then we'll change to

4
00:00:07,090 --> 00:00:11,250
executable remotely. Now, one of the

5
00:00:11,250 --> 00:00:12,830
things that we want to be able to do

6
00:00:12,830 --> 00:00:16,620
realistically is somehow manage the tasks

7
00:00:16,620 --> 00:00:19,040
or the the kind of the PowerShell commands

8
00:00:19,040 --> 00:00:21,270
that we wish to run now out of the box.

9
00:00:21,270 --> 00:00:24,390
Unfortunately, there's no SIM methods for

10
00:00:24,390 --> 00:00:27,480
starting jobs or task the such It's all

11
00:00:27,480 --> 00:00:30,560
very much you write it out and off it goes

12
00:00:30,560 --> 00:00:35,740
now. Luckily for us, we have a method

13
00:00:35,740 --> 00:00:38,460
called start job, which isn't specifically

14
00:00:38,460 --> 00:00:41,210
to do with the same commands, and it

15
00:00:41,210 --> 00:00:44,210
requires a script block. A script block is

16
00:00:44,210 --> 00:00:46,780
something that sits in those. Scroll your

17
00:00:46,780 --> 00:00:50,590
brackets. Now the nice thing is, we can do

18
00:00:50,590 --> 00:00:57,440
this we can combine the regular ones with

19
00:00:57,440 --> 00:01:01,600
the seven Incidents ones or the SIM

20
00:01:01,600 --> 00:01:03,960
commands, at least, so I'm going to say

21
00:01:03,960 --> 00:01:07,500
get system Now. What this will do is a job

22
00:01:07,500 --> 00:01:09,570
now executes, and you can see that the

23
00:01:09,570 --> 00:01:13,720
start dash job is now running that job.

24
00:01:13,720 --> 00:01:15,220
Now, of course, if I want to be able to

25
00:01:15,220 --> 00:01:19,550
see how well that's done or if it's

26
00:01:19,550 --> 00:01:24,170
completed, I can, we say receive job and I

27
00:01:24,170 --> 00:01:28,080
actually wanted IDE there we do IDE on.

28
00:01:28,080 --> 00:01:30,770
Then I'm going to say Job IDE one. And

29
00:01:30,770 --> 00:01:33,430
sure enough, it retrieved my computer

30
00:01:33,430 --> 00:01:35,390
information. You can see right here. It's

31
00:01:35,390 --> 00:01:37,900
got my desktop name. It's a work group,

32
00:01:37,900 --> 00:01:39,930
the total amount of RAM and the model

33
00:01:39,930 --> 00:01:43,540
etcetera. So I was able to kick off a job,

34
00:01:43,540 --> 00:01:47,040
but use the same instance inside of that

35
00:01:47,040 --> 00:01:48,780
now we can do a little bit further with

36
00:01:48,780 --> 00:01:50,740
this. So what we can do is I could

37
00:01:50,740 --> 00:01:54,530
actually declare a job object, say start

38
00:01:54,530 --> 00:01:57,770
job. It always requires a script block of

39
00:01:57,770 --> 00:01:59,890
some description, and then I'm going to

40
00:01:59,890 --> 00:02:05,150
say get same instance. I forgot to put em

41
00:02:05,150 --> 00:02:08,140
same instance Here. I'm going to perform a

42
00:02:08,140 --> 00:02:13,810
query and the query will be select Star

43
00:02:13,810 --> 00:02:18,740
from We'll do the wind 30 to process Like

44
00:02:18,740 --> 00:02:30,080
so where name like note had like So now

45
00:02:30,080 --> 00:02:31,500
I'm just gonna launch no thead, obviously,

46
00:02:31,500 --> 00:02:33,390
because I closed the last one. There's my

47
00:02:33,390 --> 00:02:36,960
note pad, so there's my option and

48
00:02:36,960 --> 00:02:38,850
going to close that. So this is going to

49
00:02:38,850 --> 00:02:41,250
kick off a job that's gonna be dropped

50
00:02:41,250 --> 00:02:44,590
into the job variable and retrieve the

51
00:02:44,590 --> 00:02:47,250
information. So if I click on job here.

52
00:02:47,250 --> 00:02:49,580
You'll see that my background job is IDE

53
00:02:49,580 --> 00:02:52,700
of three. It executed and it's been

54
00:02:52,700 --> 00:02:57,920
completed. Now we can use the receive. Let

55
00:02:57,920 --> 00:03:02,370
me get this right. Receive Job Command to

56
00:03:02,370 --> 00:03:04,660
be able to say the IDE of the job that I'm

57
00:03:04,660 --> 00:03:08,520
looking for is job Dark IDE. And then,

58
00:03:08,520 --> 00:03:10,650
sure enough, it returns the information

59
00:03:10,650 --> 00:03:12,490
that I'm looking for. Okay, so what about

60
00:03:12,490 --> 00:03:14,120
if we wanted to kind of tile this

61
00:03:14,120 --> 00:03:16,780
together? So first off, what I'm gonna do

62
00:03:16,780 --> 00:03:19,780
here is I'm going to populate a computer

63
00:03:19,780 --> 00:03:24,040
variable local host or be it just the

64
00:03:24,040 --> 00:03:26,280
local machine. And then what I want to be

65
00:03:26,280 --> 00:03:30,840
able to do is execute a specific command

66
00:03:30,840 --> 00:03:34,850
and then kind of have that run as a

67
00:03:34,850 --> 00:03:37,530
specific job. Now, of course, in order to

68
00:03:37,530 --> 00:03:39,610
do this, we need to kind of mix things

69
00:03:39,610 --> 00:03:41,850
around a little bit. So we're going to mix

70
00:03:41,850 --> 00:03:44,800
what would be regular PowerShell and Sim

71
00:03:44,800 --> 00:03:46,850
kind of commands together. So what we

72
00:03:46,850 --> 00:03:50,380
could do here is I could say, invoke

73
00:03:50,380 --> 00:03:52,540
command, which is actually just a regular

74
00:03:52,540 --> 00:03:54,850
PowerShell command. And then you can see

75
00:03:54,850 --> 00:03:56,540
I've got a script block that I can

76
00:03:56,540 --> 00:04:00,590
execute, then paste or utilize other

77
00:04:00,590 --> 00:04:03,030
commands that I'm trying to get to. So

78
00:04:03,030 --> 00:04:06,540
what I can do here? Say get same instance

79
00:04:06,540 --> 00:04:13,640
here and I can say, Class name Win 32

80
00:04:13,640 --> 00:04:18,020
computer system. So now I have my script

81
00:04:18,020 --> 00:04:20,670
block. Then, at this point, I actually

82
00:04:20,670 --> 00:04:23,010
have a computer name object that I can

83
00:04:23,010 --> 00:04:26,920
pass into So I can say, computer. And then

84
00:04:26,920 --> 00:04:29,910
there's also a parameter here called as

85
00:04:29,910 --> 00:04:32,040
job. Now what that means is that I'm going

86
00:04:32,040 --> 00:04:35,350
to call regular PowerShell asking for a

87
00:04:35,350 --> 00:04:37,660
script block. The script block is going to

88
00:04:37,660 --> 00:04:41,090
go and get me the instance off. Whatever

89
00:04:41,090 --> 00:04:42,600
I've asked it for, which at this instance

90
00:04:42,600 --> 00:04:45,100
will be the computer system details. And

91
00:04:45,100 --> 00:04:47,200
I'm telling the command to be executed on

92
00:04:47,200 --> 00:04:50,640
the computer as a job. So I've now

93
00:04:50,640 --> 00:04:52,850
executed that it didn't run locally,

94
00:04:52,850 --> 00:04:54,950
necessarily run it as a job. You could see

95
00:04:54,950 --> 00:04:57,840
it's called a remote job and it's running

96
00:04:57,840 --> 00:05:00,480
now. What I can do here is I can say go,

97
00:05:00,480 --> 00:05:03,630
go and receive not that one. Go and

98
00:05:03,630 --> 00:05:07,960
receive the job on the IDE for that is

99
00:05:07,960 --> 00:05:10,820
gonna be seven. So I'm gonna do that. And

100
00:05:10,820 --> 00:05:13,640
sure enough, it retrieved the information

101
00:05:13,640 --> 00:05:15,410
so you can see we can kind of combine

102
00:05:15,410 --> 00:05:17,530
things together and that's the power power

103
00:05:17,530 --> 00:05:19,650
off. PowerShell have actually been able to

104
00:05:19,650 --> 00:05:22,050
utilize SIM commands on regular PowerShell

105
00:05:22,050 --> 00:05:27,000
commands, especially when it comes to executing things as jobs locally.

