Parameters contained in a hash table

I’ve been trying to get use a hash table to pass parameters in PowerShell as discussed here: about Splatting - PowerShell | Microsoft Docs.

Here’s a very simple example that shows the problems I’m having.

$TestParams = @{
    Name="EventLog"
    Verbose=$true
}
	
Get-Service $TestParams

When I run this (in 5.1 and 7), I get the following error message. I’ve tried this with other cmdlets as well and always gets the same result. Any idea what I’m doing wrong?

Edit: I’m not sure why, but the image didn’t show up. You can see the output I get here: https://drive.google.com/file/d/1uDLTWb-sgc9UINesdgfxWP6Jq7k4a20e/view?usp=sharing.

$TestParams = @{
    Name    = "EventLog"
    Verbose = $true
}
 
Get-Service @TestParams

Thanks for the response, and I just added the spaces in like you have in your code. However, I get the exact same result. I also tried this on another computer and saw the same output.

Spaces aren’t the issue. Look at line 6. What using splatting (using a hash table to pass arguments), the variable is prefaced with an @ symbol not $. Basically if you leave the $ in you are passing the object referenced by that variable as a positional argument (position 0) and not splatting across named parameters (in this example).

Thank you. I guess I am so used to using $ that I totally overlooked that in the code and at the MS site.