Piping and Splatting

suggest change

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-WmiObject -ComputerName "Computer2" @splat
Get-WmiObject -ComputerName "Computer3" @splat

However, if the splat is not indented for reuse, you may not wish to declare it. It can be piped instead:

@{
   ComputerName = $env:COMPUTERNAME
   Class = "Win32_SystemEnclosure"
   Property = "Manufacturer"
   ErrorAction = "Stop"
} | % { Get-WmiObject @_ }

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents