WEBVTT

00:00.390 --> 00:05.380
Select object can also create custom or calculated properties.

00:05.460 --> 00:11.910
Each of these has a label or a name that Windows powers shall display in the same way it displays any

00:11.910 --> 00:13.370
built in property name.

00:13.500 --> 00:19.720
Each calculated property also has an expression that defines the contents of the property.

00:19.800 --> 00:27.610
Each calculated property is typed in a hash table the hash table the hash table is known in some and

00:27.660 --> 00:35.700
languages as an associative array a dictionary or a hash table one hash table can contain multiple items

00:35.850 --> 00:42.480
and each item consisting of a key and well you know Windows powers shall use as hash tables many times

00:42.690 --> 00:44.250
and for many purposes.

00:44.310 --> 00:50.280
In some cases you can specify your own case run a hash table is used to create calculated properties

00:50.310 --> 00:52.240
by using Select objects.

00:52.320 --> 00:57.690
You must use the keys that powers shall expect those keys are as follows.

00:57.690 --> 01:04.820
Label or just l an abbreviation for label and name or an for an abbreviation for me.

01:04.920 --> 01:12.510
Also I used to specify the label of the calculated property because the lowercase capital L resembles

01:12.560 --> 01:13.670
Lin number.

01:13.680 --> 01:23.280
In some forms try to use either name or an or label try to avoid using just L and another key is expression

01:23.310 --> 01:31.200
or just evil as a revision for expression that is used to specify the expression or the calculated property.

01:31.200 --> 01:37.890
For example suppose that you want to display a list of processes that includes each Gross's name ID

01:37.890 --> 01:40.900
virtual memory use and page memory use.

01:40.950 --> 01:47.760
You want to use the column labels virtual memory and page memory for the last two properties and you

01:47.760 --> 01:48.820
won't load.

01:48.840 --> 01:50.860
Well it is displayed in bytes.

01:51.000 --> 01:58.620
You could run the following command good process by it to select object and selected by name ID.

01:58.650 --> 02:04.110
And here we can add those calculated properties in a hash table.

02:04.200 --> 02:09.930
If you type that comment exactly at least press and enter after the vertical pipe character it'll still

02:09.930 --> 02:10.550
work.

02:10.670 --> 02:17.550
Will enter extended prompt mode after you type the rest of command press enter on a blank line to execute

02:17.730 --> 02:23.030
the command that came out and put two hash tables each one creating a calculated property.

02:23.080 --> 02:30.270
Below are character PSII to image a special variable created by those powers shall it represents whatever

02:30.330 --> 02:33.600
object was piped into select object command.

02:33.690 --> 02:40.770
In this example that is a process object of the period after Derbe dollar character parasite and lets

02:40.770 --> 02:43.570
you access a single member of the object.

02:43.620 --> 02:51.210
In this example one calculated property is used in the the property a virtual memory and the other is

02:51.210 --> 02:54.230
used as the PM property or page memory.

02:54.300 --> 03:00.450
The hash table can be easier to interpret if you write it out a bit differently.

03:00.460 --> 03:07.770
Leglise as you can see a semi-colon separates the two key you well Paris whiskey's and and they are

03:07.770 --> 03:08.460
used.

03:08.460 --> 03:15.720
These keys are expected by windows power shell there label or rename is just a stream therefore it is

03:15.720 --> 03:17.630
enclosed in quotation marks.

03:17.670 --> 03:23.170
Windows partially accepts either single or double quotation marks for this purpose.

03:23.220 --> 03:31.290
The expression is a small piece of executable code called a script block and is contained within curly

03:31.290 --> 03:32.180
braces.

03:32.180 --> 03:38.850
Please know that earlier versions of Windows POAs shell use the dollar character underscore instead

03:38.850 --> 03:44.070
of dollar character parasite unbearable that older syntax is compatible.

03:44.100 --> 03:51.680
And Windows partial 3 versions 3 and many experienced users continue to use it out of habit.

03:51.720 --> 04:00.180
Akamai separates each property from the others in the least name coma ID coma and both calculated properties

04:00.180 --> 04:01.980
are all separated by commas.

04:02.040 --> 04:04.420
So I go about format and Tibs.

04:04.470 --> 04:10.220
You might want to modify the previous command to display mummer available in Megabytes windows polish

04:10.230 --> 04:18.280
all understand that abbreviation Kaybee MBG BTB and P.B. for banter tabards as Representer the best

04:18.280 --> 04:18.560
too.

04:18.580 --> 04:23.040
Well kilobyte megabyte gigabyte terrabyte and better bind.

04:23.070 --> 04:26.540
So you might modify your command as follows.

04:26.550 --> 04:34.050
Get Prozess pipeline select object name call my ID comma first calculated property and tell them to

04:34.050 --> 04:37.430
record out divided by 1 megabyte.

04:37.470 --> 04:41.790
In addition to revised format and that makes the comment easier to read.

04:41.820 --> 04:47.760
This new example changes the column labels to include the megabyte designation.

04:47.760 --> 04:52.080
It also changes the expressions to include a division operation.

04:52.110 --> 04:55.720
Divide in each memory well by one megabyte.

04:55.800 --> 05:02.340
Unfortunately the results in a Bellerose have several decimal this which is unattractive consider this

05:02.340 --> 05:06.140
new example this new example uses Windows power shelves.

05:06.240 --> 05:13.770
Does f format an operator the left all the operation is a screen that tells Windows shell that data

05:13.950 --> 05:22.910
to display 0 call on Capitol and two in curly braces means to display the data item as a number with

05:23.070 --> 05:28.750
two decimal places to the right of the operator in the original mathematical expression.

05:28.800 --> 05:34.710
It is in parenthesis to make sure that it executes as a single unit.

05:34.740 --> 05:37.290
You can type this command out exactly as shown.

05:37.290 --> 05:40.530
Press enter on the blank line and use the results.

05:40.530 --> 05:46.250
Listen to X in that example can be confusing because there are a lot of punctuation symbols.

05:46.260 --> 05:48.450
Start with a basic expression.

05:48.450 --> 05:55.320
This one this expression divides the virtual memory property or the property by one megabyte and then

05:55.320 --> 06:02.520
format's let a number have an up to two decimal places that expression and then placed into the hash

06:02.520 --> 06:03.160
table.

06:03.240 --> 06:09.680
And it looks like Left that his table creates the custom property name to virtual memory in megabytes.

06:09.690 --> 06:14.010
You can read more about this EF operator by running.

06:14.010 --> 06:17.950
How about underscore operators in Windows power shell.

06:17.970 --> 06:24.000
Now let's have a practice grade in calculating brokerages you'll see call to use Select object to create

06:24.000 --> 06:29.280
calculated properties and create output that has calculated properties.

06:29.280 --> 06:35.490
So first let's display a list of most recent commands running in the shell get history.

06:35.490 --> 06:40.100
Now let's view the members so that objects out could buy that command to do that.

06:40.160 --> 06:46.860
Iran get history by it to get member now it looks like it's the property that contains the time that

06:47.070 --> 06:53.240
the command started to run in and the time that it finished running for that we have to locate start

06:53.260 --> 06:56.730
execution time and an execution time properties.

06:56.730 --> 07:03.240
Now let's display the same list and in it calculated property that shows the time that it took each

07:03.240 --> 07:10.970
command to run for that we could run the following command get history by select object does property

07:11.160 --> 07:18.530
find all the properties which has the asterisks for all the wildcard for all the properties and fill

07:18.530 --> 07:26.340
the create calculated property with the name execution time and expression P.S. item variable and it's

07:26.430 --> 07:30.540
property and execution time and start execution time.

07:30.550 --> 07:36.800
Now let's display the same list sorting the results by the time that it took each command to run showing

07:37.040 --> 07:43.590
longest running commands at the top of the list and shortest running commands at the bottom.

07:43.620 --> 07:52.910
We do the same as the previous example but at the pipe and sort object properties execution time Sandom.
