PowerShell formatting converts objects into human-readable screen, file, or hard-copy output. It lets you override default display rules when objects contain more properties than the default view shows. section 11.0 section 11.1
Default views define column headers, widths, alignment, and layout through .format.ps1xml files. Format- cmdlets let you request different output forms, while the formatting system chooses a view from the object type. section 11.2 section 11.9.2
Keep these boundaries in mind:
- Treat formatting as presentation rather than data transformation; Out-GridView bypasses the formatting subsystem and accepts regular objects, not Format- cmdlet output. section 11.8
- Avoid mixing unrelated object types in one pipeline. The first object determines the expected formatting, so later objects may display incompletely or fall back to a list. section 11.9.2
- Use predefined custom views when appropriate; creating custom views requires complicated XML syntax that is not publicly documented. section 11.9.2
Inspecting and changing a default view
Run `Get-Process` to observe formatted columns, then inspect a formatting definition with `cd $pshome/Modules/PSReadLine` and `code PSReadLine.format.ps1xml`. You can also inspect a type with `Get-PSReadLineKeyHandler | Get-Member` and retrieve its formatting data with `Get-FormatData -PowerShellVersion 7.1 -TypeName Microsoft.PowerShell.KeyHandler`. section 11.2
PS /Users/jamesp/> Get-Process; Get-History
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
...
0 0.00 1.74 0.25 1244 1 UsageTrackingAg
0 0.00 0.68 0.19 710 1 USBAgent
0 0.00 4.12 6.37 544 1 useractivityd
0 0.00 5.44 8.00 407 1 UserEventAgent
0 0.00 7.50 3.43 428 1 usernoted
0 0.00 3.44 8.71 506 1 ViewBridgeAuxil
0 0.00 5.91 0.08 27019 ...19 VTDecoderXPCSer
0 0.00 5.92 0.07 89048 ...48 VTDecoderXPCSer
0 0.00 10.79 50.02 434 1 WiFiAgent
0 0.00 1.11 0.20 1242 1 WiFiVelocityAge
0 0.00 10.28 4.30 20921 ...21 XprotectService
Id : 1
CommandLine : Update-TypeData -Path /tmp/Uri.Types.ps1xml
ExecutionStatus : Completed
StartExecutionTime : 9/21/2019 12:20:03 PM
EndExecutionTime : 9/21/2019 12:20:03 PM
Duration : 00:00:00.0688690
Id : 2
CommandLine : Update-TypeData -Path /tmp/Uri.Types.ps1xml
ExecutionStatus : Completed
StartExecutionTime : 9/21/2019 12:21:07 PM
EndExecutionTime : 9/21/2019 12:21:07 PM
Duration : 00:00:00.0125330eyp
Compare the readable process table with the degraded output produced when process and history objects share a pipeline. section 11.9.2






