1
00:00:01,040 --> 00:00:06,050
PowerShell does a fantastic job of formatting data in the console by default,

2
00:00:06,050 --> 00:00:08,740
but how does that actually work?

3
00:00:08,740 --> 00:00:11,950
What's going on behind the scenes between when you run a command

4
00:00:11,950 --> 00:00:14,210
and when you see the output on the screen?

5
00:00:14,210 --> 00:00:16,240
Why should you care?

6
00:00:16,240 --> 00:00:19,330
Sometimes you want to format data in different views and

7
00:00:19,330 --> 00:00:21,450
structures than what comes by default,

8
00:00:21,450 --> 00:00:24,940
and you're probably curious as to how to make that happen.

9
00:00:24,940 --> 00:00:25,190
Well,

10
00:00:25,190 --> 00:00:30,240
strap in because we're about to explore formatting and output with PowerShell.

11
00:00:30,240 --> 00:00:32,300
Hi, my name is Matt Allford,

12
00:00:32,300 --> 00:00:34,350
and I'm thrilled that you're here with me on this

13
00:00:34,350 --> 00:00:37,340
course Formatting Data in PowerShell.

14
00:00:37,340 --> 00:00:39,710
Let's cover a couple of housekeeping things,

15
00:00:39,710 --> 00:00:42,840
and then we'll get stuck into the course content.

16
00:00:42,840 --> 00:00:45,740
Firstly, as I mentioned in the course overview,

17
00:00:45,740 --> 00:00:47,830
I am making an assumption that you've got some

18
00:00:47,830 --> 00:00:50,260
experience with PowerShell already,

19
00:00:50,260 --> 00:00:53,830
nothing too advanced, but I'm expecting you're comfortable with how the

20
00:00:53,830 --> 00:00:57,960
PowerShell language system works and that it's based around objects.

21
00:00:57,960 --> 00:01:00,360
You should know how PowerShell's help system works,

22
00:01:00,360 --> 00:01:03,640
how to run and pipe commands, what parameters are,

23
00:01:03,640 --> 00:01:05,440
that kind of thing.

24
00:01:05,440 --> 00:01:10,890
Dan Stanton is a desktop support engineer for a company named Globomantics.

25
00:01:10,890 --> 00:01:13,400
Among the many tools and technologies Dan has been

26
00:01:13,400 --> 00:01:15,420
learning and using in his role,

27
00:01:15,420 --> 00:01:19,330
PowerShell has become central to being successful with managing and

28
00:01:19,330 --> 00:01:22,740
maintaining the systems that he's responsible for.

29
00:01:22,740 --> 00:01:25,830
Anna Fisher is Dan's manager at Globomantics,

30
00:01:25,830 --> 00:01:30,140
and she's recently asked Dan to start providing some information from the

31
00:01:30,140 --> 00:01:34,540
systems that he managers in an easy to read and digest format.

32
00:01:34,540 --> 00:01:36,270
Nothing too fancy is needed,

33
00:01:36,270 --> 00:01:39,330
and Dan knows he can find all of the information he

34
00:01:39,330 --> 00:01:41,150
needs by running PowerShell cmdlets.

35
00:01:41,150 --> 00:01:45,720
But he then often spends a lot of time copying and pasting information from

36
00:01:45,720 --> 00:01:50,700
the console and manually manipulating the output to get it into a format he

37
00:01:50,700 --> 00:01:54,930
knows Anna is looking for. Dan's sure there's a better way to make

38
00:01:54,930 --> 00:01:57,190
PowerShell do the heavy lifting for him,

39
00:01:57,190 --> 00:02:00,210
and the great news is that there absolutely is.

40
00:02:00,210 --> 00:02:01,510
And throughout this course,

41
00:02:01,510 --> 00:02:07,140
we're going to help Dan understand formatting and basic output with PowerShell.

42
00:02:07,140 --> 00:02:09,890
The course is comprised of two main modules,

43
00:02:09,890 --> 00:02:11,790
starting with Formatting with PowerShell,

44
00:02:11,790 --> 00:02:14,240
which is the module you're in right now.

45
00:02:14,240 --> 00:02:15,510
Throughout this module,

46
00:02:15,510 --> 00:02:17,530
we're going to spend a few minutes discussing and

47
00:02:17,530 --> 00:02:19,980
exploring PowerShell's format system,

48
00:02:19,980 --> 00:02:23,250
and you'll be able to see why and how PowerShell makes decisions

49
00:02:23,250 --> 00:02:27,180
and what rules it follows on how to format data when you aren't

50
00:02:27,180 --> 00:02:29,740
explicitly telling it what to do.

51
00:02:29,740 --> 00:02:33,200
And then there'll be times where you will want to tell PowerShell how you

52
00:02:33,200 --> 00:02:36,840
want the results of a command to be formatted and displayed.

53
00:02:36,840 --> 00:02:41,570
You'll get hands on with formatting data to a table, to a list, and as wide,

54
00:02:41,570 --> 00:02:43,830
which is kind of sort of like a table,

55
00:02:43,830 --> 00:02:47,730
but also different. We'll spend a few minutes with the formatting views,

56
00:02:47,730 --> 00:02:50,930
which are a lesser‑known capability of PowerShell's format

57
00:02:50,930 --> 00:02:53,740
system, but it's one that's worth knowing.

58
00:02:53,740 --> 00:02:54,920
To wrap things up,

59
00:02:54,920 --> 00:02:58,080
I'll show you a couple of caveats to be aware of when formatting,

60
00:02:58,080 --> 00:03:01,840
which are easy to avoid when you know about them, but a lot of beginners run

61
00:03:01,840 --> 00:03:05,840
into some common issues when exploring PowerShell formatting.

62
00:03:05,840 --> 00:03:09,120
The next module in this course covers working with PowerShell's

63
00:03:09,120 --> 00:03:12,360
Out cmdlets, which allow you to output data,

64
00:03:12,360 --> 00:03:16,430
including formatted data, to the screen or to other endpoints,

65
00:03:16,430 --> 00:03:19,140
like a file or even a printer.

66
00:03:19,140 --> 00:03:19,670
Yeah,

67
00:03:19,670 --> 00:03:25,340
an actual printer, even in 2020. I'll introduce that module a bit more in

68
00:03:25,340 --> 00:03:29,940
depth when we get to the introduction clip for that module, but for now we

69
00:03:29,940 --> 00:03:34,350
need to wrap our heads around formatting. Just before we get stuck into

70
00:03:34,350 --> 00:03:38,310
the content, I do want to call out that I try to build learning courses

71
00:03:38,310 --> 00:03:41,490
that are very hands on, and in my opinion,

72
00:03:41,490 --> 00:03:43,740
this course is no exception.

73
00:03:43,740 --> 00:03:46,240
Most of the clips in this course are demo clips,

74
00:03:46,240 --> 00:03:49,740
where we'll be spending time at the PowerShell console.

75
00:03:49,740 --> 00:03:52,800
I also firmly believe that you will get the most out of

76
00:03:52,800 --> 00:03:55,290
this course if you follow along with me,

77
00:03:55,290 --> 00:03:57,840
so I really encourage you to do so.

78
00:03:57,840 --> 00:04:01,620
Now, you can do that clip by clip as we go, or you might prefer to

79
00:04:01,620 --> 00:04:04,680
watch a series of clips and then go through the activities and lab

80
00:04:04,680 --> 00:04:07,130
exercises on your own at the end, which,

81
00:04:07,130 --> 00:04:09,040
of course, is perfectly fine.

82
00:04:09,040 --> 00:04:10,890
There are two things that I want to bring to your

83
00:04:10,890 --> 00:04:13,640
attention to help you be successful.

84
00:04:13,640 --> 00:04:16,840
The first is that there are exercise files included with

85
00:04:16,840 --> 00:04:19,540
this course on the Pluralsight portal.

86
00:04:19,540 --> 00:04:21,910
When you download those exercise files,

87
00:04:21,910 --> 00:04:26,100
I've included all of the commands that you'll see me run in this course inside

88
00:04:26,100 --> 00:04:30,040
of text‑based files with a brief description of what they do.

89
00:04:30,040 --> 00:04:34,740
The folders inside of the exercise files are laid out per module, so

90
00:04:34,740 --> 00:04:37,840
you'll see a folder for module 2, which is this module,

91
00:04:37,840 --> 00:04:41,740
and you'll see a folder for module 3, which is the next module.

92
00:04:41,740 --> 00:04:45,400
I do strongly believe that you'll solidify your knowledge more quickly

93
00:04:45,400 --> 00:04:48,210
if you type the commands yourself and make mistakes.

94
00:04:48,210 --> 00:04:53,340
But if you prefer to copy and paste the commands, please feel free to do so.

95
00:04:53,340 --> 00:04:56,740
The second thing I want to show you is my demo environment, and

96
00:04:56,740 --> 00:04:59,530
we'll be spending most of the time in this course in my

97
00:04:59,530 --> 00:05:02,240
environment at the PowerShell console.

98
00:05:02,240 --> 00:05:04,450
Now, I want to point out that you don't have to be

99
00:05:04,450 --> 00:05:06,680
set up exactly the same as I am.

100
00:05:06,680 --> 00:05:11,220
You're probably aware by now, but PowerShell is a multi‑platform utility,

101
00:05:11,220 --> 00:05:14,800
and all of these exercises will work just as well on

102
00:05:14,800 --> 00:05:17,740
Linux or Mac as they do on Windows.

103
00:05:17,740 --> 00:05:18,760
With that said,

104
00:05:18,760 --> 00:05:22,700
I've got a Windows 10 desktop and I've followed the installing

105
00:05:22,700 --> 00:05:25,980
PowerShell section of Jeff Hicks's Installing and Running

106
00:05:25,980 --> 00:05:29,940
PowerShell course to get PowerShell 7 installed.

107
00:05:29,940 --> 00:05:35,350
If I run Get‑ComputerInfo and select the WindowsProductName and the

108
00:05:35,350 --> 00:05:40,650
WindowsVersion, you'll see I'm on Windows 10 Pro and version 2004.

109
00:05:40,650 --> 00:05:41,640
But like I said,

110
00:05:41,640 --> 00:05:45,380
you don't need to be on this build of Windows or even Windows at all.

111
00:05:45,380 --> 00:05:49,740
As long as you're running version 7 of PowerShell, that's the main thing.

112
00:05:49,740 --> 00:05:52,140
If I run $PSVersionTable,

113
00:05:52,140 --> 00:05:57,790
you'll see here that I'm running version 7.0.3 of PowerShell. Hmm, I

114
00:05:57,790 --> 00:06:05,000
think that's the housekeeping stuff out of the way. Let's get stuck into looking at the PowerShell format system.

