What is splatting?
Documentation: Microsoft Learn
Explain PowerShell splatting, named parameter hashtables, conditional options and the difference between $params and @params.
Interview · Question 4 of 34
Answer before reveal
Your draft
Write the answer you would give in an interview. The model answer stays hidden until you have drafted at least a short response.
A strong answer
Splatting passes a collection of arguments to a command. With a hashtable, the keys are parameter names without their leading hyphens and the values are the arguments. Create the hashtable in a normal variable such as $params, then use @params at the command call. Passing $params instead supplies the hashtable itself as an argument.
The main benefit is readability: a command with several options becomes a short invocation and a clearly named configuration block. You can add an optional key only when its value is available, or reuse a common set of options across similar calls. An array can also be splatted, but its entries bind positionally, which is less explicit for administrative scripts.
In an interview, explain the boundary as well as the convenience. Splatting does not validate whether a parameter is supported or whether a combination belongs to the same parameter set. Check the target command help, keep sensitive values out of logs, and prefer descriptive hashtable names when multiple commands use different options.