commands

^

Select-DbaObject

Author Friedrich Weinmann (@FredWeinmann)
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Select-DbaObject on GitHub.
Want to see the Bill Of Health for this command? Check out Select-DbaObject.

Synopsis

Wrapper around Select-Object, extends property parameter.

Description

Wrapper around Select-Object, extends property parameter.

        This function allows specifying in-line transformation of the properties specified without needing to use complex hashtables.
        For example, renaming a property becomes as simple as 'Length as Size'

        Also supported:

        - Specifying a typename

        - Picking the default display properties

        - Adding to an existing object without destroying its type

        See the description of the Property parameter for an exhaustive list of legal notations for in-line transformations.

Syntax

Select-DbaObject
    [-Property <DbaSelectParameter[]>]
    [-Alias <SelectAliasParameter[]>]
    [-ScriptProperty <SelectScriptPropertyParameter[]>]
    [-ScriptMethod <SelectScriptMethodParameter[]>]
    [-InputObject ]
    [-ExcludeProperty <string[]>]
    [-ExpandProperty ] -Unique
    [-Last ]
    [-First ]
    [-Skip ] -Wait
    [-ShowProperty <string[]>]
    [-ShowExcludeProperty <string[]>]
    [-TypeName ] -KeepInputObject
    []            

Select-DbaObject
    [-Property <DbaSelectParameter[]>]
    [-Alias <SelectAliasParameter[]>]
    [-ScriptProperty <SelectScriptPropertyParameter[]>]
    [-ScriptMethod <SelectScriptMethodParameter[]>]
    [-InputObject ]
    [-ExcludeProperty <string[]>]
    [-ExpandProperty ] -Unique
    [-SkipLast ]
    [-ShowProperty <string[]>]
    [-ShowExcludeProperty <string[]>]
    [-TypeName ] -KeepInputObject
    []            

Select-DbaObject
    [-InputObject ] -Unique -Wait
    [-Index <int[]>]
    [-ShowProperty <string[]>]
    [-ShowExcludeProperty <string[]>]
    [-TypeName ] -KeepInputObject
    []

 

Examples

 

Example 1: Renaming a property
        Get-ChildItem | Select-DbaObject Name, "Length as Size"<br>
        Selects the properties Name and Length, renaming Length to Size in the process.<br>
Example 2: Converting type
        Import-Csv .\file.csv | Select-DbaObject Name, "Length as Size to DbaSize"<br>
        Selects the properties Name and Length, renaming Length to Size and converting it to [DbaSize] (a userfriendly representation of<br>
        size numbers contained in the dbatools module)<br>
Example 3: Selecting from another object 1
        $obj = [PSCustomObject]@{ Name = "Foo" }<br>
        Get-ChildItem | Select-DbaObject FullName, Length, "Name from obj"<br>
        Selects the properties FullName and Length from the input and the Name property from the object stored in $obj<br>
Example 4: Selecting from another object 2
        $list = @()<br>
        $list += [PSCustomObject]@{ Type = "Foo"; ID = 1 }<br>
        $list += [PSCustomObject]@{ Type = "Bar"; ID = 2 }<br>
        $obj | Select-DbaObject Name, "ID from list WHERE Type = Name"<br>
        This allows you to LEFT JOIN contents of another variable. Note that it can only do simple property-matching at this point.<br>
        It will select Name from the objects stored in $obj, and for each of those the ID Property on any object in $list that has a<br>
        Type property of equal value as Name on the input.<br>
Example 5: Naming and styling
        Get-ChildItem | Select-DbaObject Name, Length, FullName, Used, LastWriteTime, Mode -TypeName MyType -ShowExcludeProperty Mode,<br>
        Used<br>
        Lists all items in the current path, selects the properties specified (whether they exist or not) , then ...<br>
        - Sets the name to "MyType"<br>
        - Hides the properties "Mode" and "Used" from the default display set, causing them to be hidden from default view<br>

Optional Parameters

-Alias

Alias
Required False
Pipeline false
Default Value
-ExcludeProperty

Alias
Required False
Pipeline false
Default Value
-ExpandProperty

Alias
Required False
Pipeline false
Default Value
-First

Alias
Required False
Pipeline false
Default Value
-Index

Alias
Required False
Pipeline false
Default Value
-InputObject

Alias
Required False
Pipeline true (ByValue)
Default Value
-KeepInputObject

Alias
Required False
Pipeline false
Default Value
-Last

Alias
Required False
Pipeline false
Default Value
-Property

Alias
Required False
Pipeline false
Default Value
-ScriptMethod

Alias
Required False
Pipeline false
Default Value
-ScriptProperty

Alias
Required False
Pipeline false
Default Value
-ShowExcludeProperty

Alias
Required False
Pipeline false
Default Value
-ShowProperty

Alias
Required False
Pipeline false
Default Value
-Skip

Alias
Required False
Pipeline false
Default Value
-SkipLast

Alias
Required False
Pipeline false
Default Value
-TypeName

Alias
Required False
Pipeline false
Default Value
-Unique

Alias
Required False
Pipeline false
Default Value
-Wait

Alias
Required False
Pipeline false
Default Value