A PowerShell hash table stores values under named keys. Use it when a script needs a compact collection of parameter values, output properties, or gradually assembled results. section 12.1 section 12.2
Common automation uses include:
- Build an arguments hash table conditionally, such as including StartName only when a new username was supplied. section 10.5.3
- Splat command parameters by passing the variable with @ instead of $, keeping long command calls readable. section 12.1
- Construct output properties before creating an object, then send the object through the pipeline. section 12.2
- Add properties as results become available, allowing success and failure paths to produce the same structured output. section 25.5.3
Splatting a CIM query
Create a parameter dictionary and pass it to the command with @params. Switch parameters receive $True as their value. $params = @{'ClassName'='Win32_OperatingSystem' 'ComputerName'='CLIENT1' 'Verbose'=$True} Get-CimInstance @params The same pattern can hold separate parameter sets for operating-system, computer-system, drive, and processor queries. section 12.1
Building structured output
Use keys as property names and values as collected data, then create an object for pipeline consumers. $props = @{'ComputerName'=$computer 'OSVersion'=$os.version 'RAM'=($cs.totalphysicalmemory / 1GB)} $obj = New-Object -TypeName PSObject -Property $props Write-Output $obj A normal hash table may display properties in an unexpected order. Use formatting or Select-Object when presentation order matters; an ordered hash table is possible but usually unnecessary. section 12.2 section 12.3
# Output data
$props = @{'ComputerName'=$computer
'OSVersion'=$os.version
'SPVersion'=$os.servicepackmajorversion
'OSBuild'=$os.buildnumber
'Manufacturer'=$cs.manufacturer
'Model'=$cs.model
'Procs'=$cs.numberofprocessors
'Cores'=$cs.numberoflogicalprocessors
'RAM'=($cs.totalphysicalmemory / 1GB)
'Arch'=$proc.addresswidth
'SysDriveFreeSpace'=$drive.freespace}
$obj = New-Object -TypeName PSObject -Property $props
Write-Output $obj
Inspect a complete property dictionary that turns computer information into reusable pipeline output. section 12.2









































