Created
February 9, 2022 21:18
-
-
Save pstakuu/174de57527405c87031fb6a52d31d791 to your computer and use it in GitHub Desktop.
Calculated Properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $exampleData = [PsCustomObject]@{ | |
| SimpleField1 = "user" | |
| ComplexField2 = @{ | |
| Property1 = "value1" | |
| Property2 = "value2" | |
| } | |
| } | |
| <# | |
| $exampleData | |
| Name Value | |
| ---- ----- | |
| ComplexField2 {Property1, Property2} | |
| SimpleField1 user | |
| $exampleData.ComplexField2 | |
| Name Value | |
| ---- ----- | |
| Property1 value1 | |
| Property2 value2 | |
| #> | |
| $exampleData | Select-Object SimpleField1,@{Name = "Property1 of ComplexField"; Expression = {$_.ComplexField2.Property1}},@{N = "N is shorthand for Name"; E = {"E is shorthand for Expression and is a scriptblock"}} | |
| <# | |
| $exampleData | Select-Object SimpleField1,@{Name = "Property1 of ComplexField"; Expression = {$_.ComplexField2.Property1}},@{N = "N is shorthand for Name"; E = {"E is shorthand for Expression and is a scriptblock"}} | |
| SimpleField1 Property1 of ComplexField N is shorthand for Name | |
| ------------ ------------------------- ----------------------- | |
| user value1 E is shorthand for Expression and is a scriptblock | |
| #> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment