~3 min read • Updated Dec 21, 2025
1. Splatting: Bundling Parameters
Splatting allows you to pass parameters as a hash table using @ instead of typing each parameter manually. This is ideal for reusable or repetitive commands.
$params = @{
Class = 'Win32_LogicalDisk'
ComputerName = 'SERVER2'
Filter = "DriveType=3"
Credential = $cred
}
Get-WmiObject @params
You can mix splatted parameters with manually typed ones. Splatting improves readability and reduces duplication in scripts.
2. Default Parameter Values ($PSDefaultParameterValues)
Introduced in PowerShell v3, this feature lets you define default parameter values for the current session—or permanently via your profile.
$PSDefaultParameterValues = @{
"Get-WmiObject:Class" = "Win32_OperatingSystem"
"Format-Wide:Column" = 4
}
$PSDefaultParameterValues.Add("Get-ChildItem:Force", $true)
Defaults can be overridden manually at any time. Use Remove() to clear specific entries.
3. Subexpressions in Quotes: $($expression)
Subexpressions allow you to embed evaluated expressions inside double‑quoted strings.
Write-Host "Free space: $(100 - ($free/$total*100))%" Write-Host "Service: $($service.Name)"
This avoids awkward concatenation and ensures variables and expressions expand correctly.
4. Parentheticals as Objects
Anything inside parentheses () executes first, and the result is treated as an object. This eliminates the need for intermediate variables.
(Get-Process conhost | Select -First 1).ID
Parenthetical execution is especially useful for one‑liners and quick lookups.
5. Increasing the Format Enumeration Limit
By default, PowerShell only displays the first four items of a collection. You can increase this limit:
$FormatEnumerationLimit = 8 # or -1 for unlimited
Set this in your profile for persistent behavior.
6. Hash Tables as Objects (PowerShell v3+)
You can cast hash tables directly into objects using [PSCustomObject]. This is perfect for structured output and custom objects.
[PSCustomObject]@{
Name = 'PowerShell'
Version = 7
}
Use [ordered] to preserve key order when needed.
7. Running External Utilities
External commands return plain text, but you can convert them into objects for easier processing.
driverquery /fo csv | ConvertFrom-Csv
For complex argument strings, Invoke-Expression can help, though it should be used carefully.
Conclusion
These advanced PowerShell techniques streamline automation, reduce repetitive code, and make scripts more readable and maintainable. By mastering splatting, default parameters, subexpressions, parenthetical execution, and object casting, you can work with PowerShell at an expert level and dramatically increase your efficiency.
Written & researched by Dr. Shahin Siami