Public/Clear-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
function Clear-DefaultPropertySet {
    <#
    .SYNOPSIS
    Removes all Properties from the Default Display Property Set of an Object.
 
    .DESCRIPTION
    The Clear-DefaultPropertySet function removes 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
    Clear-DefaultPropertySet -Object $DemoObject1
 
    This command clears the properties from $DemoObject1's Default Display
    Property Set.
 
    .EXAMPLE
    $DemoObject1, $DemoObject2 | Clear-DefaultPropertySet
 
    This command clears the properties from 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) {
            $Obj.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Clear()
        }
    }

    End {}
}