1
00:00:01,040 --> 00:00:05,360
PowerShell ships out of the box with a number of cmdlets that are known as

2
00:00:05,360 --> 00:00:09,740
the out cmdlets that let you control data output directly.

3
00:00:09,740 --> 00:00:13,450
These cmdlets use the PowerShell verb out because they send

4
00:00:13,450 --> 00:00:18,040
information out from PowerShell to somewhere else.

5
00:00:18,040 --> 00:00:21,750
You can find these commands by running Get‑Command ‑Verb

6
00:00:21,750 --> 00:00:25,930
out. And on screen here, I've piped that to Select‑Object

7
00:00:25,930 --> 00:00:28,140
just to get the command name.

8
00:00:28,140 --> 00:00:30,000
There are more results than these two,

9
00:00:30,000 --> 00:00:33,840
but I wanted to pause on Out‑Default and Out‑Host briefly.

10
00:00:33,840 --> 00:00:37,430
We pretty much covered these in the previous module when we spoke about

11
00:00:37,430 --> 00:00:41,470
the formatting system in PowerShell, so I'm not going to have dedicated

12
00:00:41,470 --> 00:00:44,540
demo clips in this module to walk through them.

13
00:00:44,540 --> 00:00:47,450
Just to summarize, Out‑Default is automatically

14
00:00:47,450 --> 00:00:49,610
added to the end of every pipeline,

15
00:00:49,610 --> 00:00:54,770
and it decides on how to format and output objects. Out‑Host sends

16
00:00:54,770 --> 00:00:57,230
the output to the PowerShell host for display,

17
00:00:57,230 --> 00:00:58,780
and because it's the default,

18
00:00:58,780 --> 00:01:03,340
you don't have to specify unless you want to use its parameters.

19
00:01:03,340 --> 00:01:05,430
These are the rest of the out cmdlets,

20
00:01:05,430 --> 00:01:08,220
and we'll be spending a couple of minutes with each of these

21
00:01:08,220 --> 00:01:11,340
cmdlets in the remainder of this module.

22
00:01:11,340 --> 00:01:14,730
There's a couple of fundamental concepts with the out cmdlets.

23
00:01:14,730 --> 00:01:16,190
Firstly,

24
00:01:16,190 --> 00:01:21,740
and this is really important, out cmdlets do not format objects. Out

25
00:01:21,740 --> 00:01:25,390
cmdlets know what to do with formatted data, but if an out cmdlet

26
00:01:25,390 --> 00:01:27,750
receives an object that is not formatted,

27
00:01:27,750 --> 00:01:31,200
it will invoke PowerShell's formatting system to format the object,

28
00:01:31,200 --> 00:01:35,590
which is something we covered in the last module. The out cmdlets,

29
00:01:35,590 --> 00:01:37,600
except for Out‑GridView,

30
00:01:37,600 --> 00:01:41,120
are expecting formatted data, either because it has been

31
00:01:41,120 --> 00:01:44,410
formatted by the default views and rules or because you have

32
00:01:44,410 --> 00:01:47,440
specified the formatting in the pipeline.

33
00:01:47,440 --> 00:01:50,740
You can pipe directly to an out cmdlet in the pipeline.

34
00:01:50,740 --> 00:01:55,490
Or alternatively, each out cmdlet does have an input object parameter,

35
00:01:55,490 --> 00:02:00,540
allowing you to specify the data that the out cmdlet needs to work with.

36
00:02:00,540 --> 00:02:03,840
With the exception of Out‑String, the out cmdlets

37
00:02:03,840 --> 00:02:06,340
don't output objects to the pipeline.

38
00:02:06,340 --> 00:02:08,330
When you use an out cmdlet,

39
00:02:08,330 --> 00:02:12,080
you're telling PowerShell that you're done with the object stream and you no

40
00:02:12,080 --> 00:02:16,340
longer want it to be available for further use in the console.

41
00:02:16,340 --> 00:02:20,040
Because out cmdlets don't output objects to the pipeline,

42
00:02:20,040 --> 00:02:23,740
you need to put out cmdlets at the end of the pipeline.

43
00:02:23,740 --> 00:02:26,580
If you try to pipe an out cmdlet to something else,

44
00:02:26,580 --> 00:02:34,000
it's just not going to work as the out cmdlet will not continue to pass the current objects down the pipeline.

