Splatting parameters
suggest changeSplatting replaces the dollar sign $ with @ on a variable that holds a hashtable of parameter names and values.
$MyParameters = @{
Name = "iexplore"
FileVersionInfo = $true
}
Get-Process @MyParameters
Without splatting:
Get-Process -Name "iexplore" -FileVersionInfo
You can combine normal parameters with splatted parameters to easily add common parameters to your calls.
$MyParameters = @{
ComputerName = "StackOverflow-PC"
}
Get-Process -Name "iexplore" @MyParameters
Invoke-Command -ScriptBlock { "Something to execute remotely" } @MyParameters
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents