Splatting is done by replacing the dollar-sign $ with the splatting operator @ when using a variable containing a HashTable of parameters and values in a command call.
$MyParameters = @{
Name = "iexplore"
FileVersionInfo = $true
}
Get-Process @MyParameters
Without splatti...
To use Splatting to call Get-Process with the -FileVersionInfo switch similar to this:
Get-Process -FileVersionInfo
This is the call using splatting:
$MyParameters = @{
FileVersionInfo = $true
}
Get-Process @MyParameters
Note: This is useful because you can create a default set of p...
Declaring the splat is useful for reusing sets of parameters multiple times or with slight variations:
$splat = @{
Class = "Win32_SystemEnclosure"
Property = "Manufacturer"
ErrorAction = "Stop"
}
Get-WmiObject -ComputerName $env:COMPUTERNAME @splat
Get...
Without splatting it is very cumbersome to try and pass values down through the call stack. But if you combine splatting with the power of the @PSBoundParameters then you can pass the top level parameter collection down through the layers.
Function Outer-Method
{
Param
(
[string...