Select object can also create custom or calculated properties.
Each of these has a label or a name that Windows powers shall display in the same way it displays any
built in property name.
Each calculated property also has an expression that defines the contents of the property.
Each calculated property is typed in a hash table the hash table the hash table is known in some and
languages as an associative array a dictionary or a hash table one hash table can contain multiple items
and each item consisting of a key and well you know Windows powers shall use as hash tables many times
and for many purposes.
In some cases you can specify your own case run a hash table is used to create calculated properties
by using Select objects.
You must use the keys that powers shall expect those keys are as follows.
Label or just l an abbreviation for label and name or an for an abbreviation for me.
Also I used to specify the label of the calculated property because the lowercase capital L resembles
Lin number.
In some forms try to use either name or an or label try to avoid using just L and another key is expression
or just evil as a revision for expression that is used to specify the expression or the calculated property.
For example suppose that you want to display a list of processes that includes each Gross's name ID
virtual memory use and page memory use.
You want to use the column labels virtual memory and page memory for the last two properties and you
won't load.
Well it is displayed in bytes.
You could run the following command good process by it to select object and selected by name ID.
And here we can add those calculated properties in a hash table.
If you type that comment exactly at least press and enter after the vertical pipe character it'll still
work.
Will enter extended prompt mode after you type the rest of command press enter on a blank line to execute
the command that came out and put two hash tables each one creating a calculated property.
Below are character PSII to image a special variable created by those powers shall it represents whatever
object was piped into select object command.
In this example that is a process object of the period after Derbe dollar character parasite and lets
you access a single member of the object.
In this example one calculated property is used in the the property a virtual memory and the other is
used as the PM property or page memory.
The hash table can be easier to interpret if you write it out a bit differently.
Leglise as you can see a semi-colon separates the two key you well Paris whiskey's and and they are
used.
These keys are expected by windows power shell there label or rename is just a stream therefore it is
enclosed in quotation marks.
Windows partially accepts either single or double quotation marks for this purpose.
The expression is a small piece of executable code called a script block and is contained within curly
braces.
Please know that earlier versions of Windows POAs shell use the dollar character underscore instead
of dollar character parasite unbearable that older syntax is compatible.
And Windows partial 3 versions 3 and many experienced users continue to use it out of habit.
Akamai separates each property from the others in the least name coma ID coma and both calculated properties
are all separated by commas.
So I go about format and Tibs.
You might want to modify the previous command to display mummer available in Megabytes windows polish
all understand that abbreviation Kaybee MBG BTB and P.B. for banter tabards as Representer the best
too.
Well kilobyte megabyte gigabyte terrabyte and better bind.
So you might modify your command as follows.
Get Prozess pipeline select object name call my ID comma first calculated property and tell them to
record out divided by 1 megabyte.
In addition to revised format and that makes the comment easier to read.
This new example changes the column labels to include the megabyte designation.
It also changes the expressions to include a division operation.
Divide in each memory well by one megabyte.
Unfortunately the results in a Bellerose have several decimal this which is unattractive consider this
new example this new example uses Windows power shelves.
Does f format an operator the left all the operation is a screen that tells Windows shell that data
to display 0 call on Capitol and two in curly braces means to display the data item as a number with
two decimal places to the right of the operator in the original mathematical expression.
It is in parenthesis to make sure that it executes as a single unit.
You can type this command out exactly as shown.
Press enter on the blank line and use the results.
Listen to X in that example can be confusing because there are a lot of punctuation symbols.
Start with a basic expression.
This one this expression divides the virtual memory property or the property by one megabyte and then
format's let a number have an up to two decimal places that expression and then placed into the hash
table.
And it looks like Left that his table creates the custom property name to virtual memory in megabytes.
You can read more about this EF operator by running.
How about underscore operators in Windows power shell.
Now let's have a practice grade in calculating brokerages you'll see call to use Select object to create
calculated properties and create output that has calculated properties.
So first let's display a list of most recent commands running in the shell get history.
Now let's view the members so that objects out could buy that command to do that.
Iran get history by it to get member now it looks like it's the property that contains the time that
the command started to run in and the time that it finished running for that we have to locate start
execution time and an execution time properties.
Now let's display the same list and in it calculated property that shows the time that it took each
command to run for that we could run the following command get history by select object does property
find all the properties which has the asterisks for all the wildcard for all the properties and fill
the create calculated property with the name execution time and expression P.S. item variable and it's
property and execution time and start execution time.
Now let's display the same list sorting the results by the time that it took each command to run showing
longest running commands at the top of the list and shortest running commands at the bottom.
We do the same as the previous example but at the pipe and sort object properties execution time Sandom.