UNCLASSIFIED

Skip to content
Snippets Groups Projects
Commit 2ebe7165 authored by Christopher Lees's avatar Christopher Lees :no_mobile_phones:
Browse files

Clarified how format-table uses a hash table that utilizes a script block

parent a7470992
No related merge requests found
Pipeline #79035 failed with stage
in 2 seconds
# Displaying certain properties
# Displaying certain properties
Get-Service | Format-Table Name, Status
# Change Column Headings
$cols = @{express = { [int]($_.Length/1KB) }; Label="KB" }
$cols = @{Label="KB"; Expression = { [int]($_.Length/1KB) } }
Get-ChildItem | Format-Table Name, $cols
# The above hash table feeds into a format that the Format Table cmdlet will accept.
# The hash table is made up of two fields; `Label` and `Expression`.
# Of note, `Expression` is a script block, and will place its resulting output on the field designated by `Label`.
# As `Format-Table` will process objects off the pipeline, it can interact with the `$_` automatic variable.
----
Source: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/format-table?view=powershell-5.1
----
# Grouping using formatting cmdlets
# Group by extension
Get-ChildItem | Format-Table -GroupBy Extension
\ No newline at end of file
Get-ChildItem | Sort-Object -Property Extension | Format-Table -GroupBy Extension
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment