Skip to content

Commit

Permalink
tip: New tip for select-object *
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlydog committed Oct 31, 2023
1 parent 5c16e71 commit bc33af7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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.
10 changes: 10 additions & 0 deletions src/tiPS/PowerShellTips.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,15 @@
"https://devblogs.microsoft.com/scripting/how-to-use-powershell-to-write-to-event-logs/"
],
"Category": 3
},
{
"CreatedDate": "2023-10-31T00:00:00",
"Title": "Use Select-Object * to see all object properties",
"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.\r\n\r\nTo see all properties of an object, and their values, use the `Select-Object` cmdlet with the `-Property *` parameter.",
"Example": "# See the properties of an object shown by default (for comparison).\r\nGet-Process | Select-Object -First 1\r\n\r\n# See all properties of an object.\r\nGet-Process | Select-Object -First 1 -Property *\r\n\r\n# Shorthand alternatives for Select-Object -Property *.\r\nGet-Process | Select-Object -First 1 *\r\nGet-Process | Select-Object *\r\nGet-Process | Select *",
"Urls": [
"https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-object"
],
"Category": 3
}
]

0 comments on commit bc33af7

Please sign in to comment.