For those instances, PowerShell has thecalculated propertiesconstruct.

In practice, what does this look like?

How about taking one date format, and changing to a different format?

/wordpress/wp-content/uploads/csit/2020/12/8daf4b90.png

There are several keys that we can define to manipulate the output.

What does this look like in practice?

ForSelect-Objectyou will typically only useNameandExpression.

/wordpress/wp-content/uploads/csit/2020/12/6c2c292d.png

Below is an example of what this looks like in practice!

First, we will start with the same object that we will use to demonstrate all the examples below.

Looking at the date, it doesn’t quite match what is expected.

/wordpress/wp-content/uploads/csit/2020/12/6488764c.png

Let’s change this to a different format.

Therefore we can change up the date format using a calculated property like below.

With the below code, we are changing the date format toMM/dd/yyyyusing theFormatparameter ofGet-Date.

/wordpress/wp-content/uploads/csit/2020/12/9c49c320.png

Read on to learn how to output better-formatted data.

Format-Table and Calculated Properties

The default view ofFormat-Tablemay leave something to be desired.

Therefore, let’s see what we can do to make it a bit better to work with.

Using the same object as originally defined, what does the output look like?

We can make this look better, for sure!

First off, the alignment is not ideal forNumberorEnabled.

Second, we should outputNumberwith two decimal points.

Finally, let’s makeNamewider, changeDateto our new format, and joinExtraby commas.

See below, how we can use calculated properties to change the view!