Public/Get-DefaultPropertySet.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function Get-DefaultPropertySet {
    <#
    .SYNOPSIS
    Gets all Properties from the Default Display Property Set of an Object.
 
    .DESCRIPTION
    The Get-DefaultPropertySet function gets all Properties from the Default
    Display Property Set of a PSCustomObject or collection of PSCustomObjects.
 
    .PARAMETER Object
    PSCustomObject(s) with an existing Default Display Property Set.
 
    .EXAMPLE
    Get-DefaultPropertySet -Object $DemoObject1
 
    This example lists the properties included in $DemoObject1's Default Display
    Property Set.
 
    .EXAMPLE
    $DemoObject1, $DemoObject2 | Get-DefaultPropertySet
 
    This example lists the properties included in both $DemoObject1 and
    $DemoObject2's Default Display Property Set.
 
    .LINK
    https://github.com/Windos/DefaultPropertySetter
    #>


    [CmdletBinding()]
    param (
        [Parameter(Mandatory,
                   ValueFromPipeline)]
        [PSCustomObject[]] $Object
    )

    Begin {}

    Process {
        foreach ($Obj in $Object) {
            [PSCustomObject] @{
                DisplaySet = $Obj.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames
            }
        }
    }

    End {}
}