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?
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).