generated from deadlydog/Template.NewGitRepo
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/PowerShellTips/2023-10-31-use-select-object--to-see-all-object-properties.ps1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
$tip = [tiPS.PowerShellTip]::new() | ||
$tip.CreatedDate = [DateTime]::Parse('2023-10-31') | ||
$tip.Title = 'Use Select-Object * to see all object properties' | ||
$tip.TipText = @' | ||
When an object is written to the console, PowerShell by default hides many of its properties. This is to make the output easier to read, but it can hide many useful properties that you may not know exist. This can be detrimental when interactively exploring objects in the console. | ||
To see all properties of an object, and their values, use the `Select-Object` cmdlet with the `-Property *` parameter. | ||
'@ | ||
$tip.Example = @' | ||
# See the properties of an object shown by default (for comparison). | ||
Get-Process | Select-Object -First 1 | ||
# See all properties of an object. | ||
Get-Process | Select-Object -First 1 -Property * | ||
# Shorthand alternatives for Select-Object -Property *. | ||
Get-Process | Select-Object -First 1 * | ||
Get-Process | Select-Object * | ||
Get-Process | Select * | ||
'@ | ||
$tip.Urls = @( | ||
'https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-object' | ||
) | ||
$tip.Category = [tiPS.TipCategory]::NativeCmdlet # Community, Editor, Module, NativeCmdlet, Performance, Security, Syntax, Terminal, or Other. | ||
|
||
# Community: Social events and community resources. e.g. PowerShell Summit, podcasts, etc. | ||
# Editor: Editor tips and extensions. e.g. VSCode, ISE, etc. | ||
# Module: Modules and module tips. e.g. PSScriptAnalyzer, Pester, etc. | ||
# NativeCmdlet: Native cmdlet tips. e.g. Get-Process, Get-ChildItem, Get-Content, etc. | ||
# Performance: Tips to improve runtime performance. e.g. foreach vs ForEach-Object, ForEach-Object -Parallel, etc. | ||
# Security: Security tips. e.g. ExecutionPolicy, Constrained Language Mode, passwords, etc. | ||
# Syntax: Syntax tips. e.g. splatting, pipeline, etc. | ||
# Terminal: Terminal shortcuts and tips. e.g. PSReadLine, Windows Terminal, ConEmu, etc. | ||
# Other: Tips that don't fit into any of the other categories. |
This file contains 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