external help file | Module Name | online version | schema |
---|---|---|---|
PSPreworkout-help.xml |
PSPreworkout |
2.0.0 |
Show an object without its empty properties.
Show-WithoutEmptyProperty [-Object] <Object> [<CommonParameters>]
This function shows the properties of an object with all of its empty properties filtered out.
Show-WithoutEmptyProperty -Object $Object
$Desk = [PSCustomObject]@{
Model = 'PSDesk'
Height = $null
Width = $null
Colors = @('Black', 'Gray')
Adjustable = $true
}
$Object = New-Object -TypeName PSObject -Property $Desk
Show-WithoutEmptyProperty -Object $Object
This example creates an object from a hash table and then shows that object's properties that have values.
Show-WithoutEmptyProperty -Object (Get-Item $HOME)
This example gets the home folder object while invoking the function.
$Object | Show-WithoutEmptyProperty
This example shows how an object can be piped to the function.
Get-ChildItem $HOME | Select-Object -First 1 | Show-WithoutEmptyProperty
This example gets the home folder object and pipes it to the Show-WithoutEmptyProperty function.
The object to show.
Type: Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
Author: Sam Erde Version: 1.0.0 Modified: 2024-10-23
I am grateful to Jeffrey Hicks for guiding me towards an understanding of how to complete this function and for providing even nicer code than I started with. I encourage you to reach out to him for PowerShell training and subscribe to his newsletter! 🙏
https://jdhitsolutions.github.io/
https://www.linkedin.com/in/jefferyhicks/
https://twitter.com/JeffHicks