A PowerShell Parameter Puzzler

I ran across an interesting PowerShell behavior today thanks to a coworker (hi Matt!). It involved a function with just a few arguments. When I looked at the syntax something looked off. I am not going to recreate the exact scenario I found (because it involved a cmdlet written in C#), but I was able …

Continue reading ‘A PowerShell Parameter Puzzler’ »

Old School PowerShell Expressions vs New

In a recent StackOverflow answer, I wrote the following PowerShell to find parameters that were in a given parameter set (edited somewhat for purposes of this post): A quick note…it’s not correct. It only shows parameters that are explicitly in the parameter set. Items that aren’t marked with any parameter set are in all parameter …

Continue reading ‘Old School PowerShell Expressions vs New’ »

Deciphering PowerShell Syntax Help Expressions

In my last post I showed several instances of the syntax help that you get when you use get-help or -? with a cmdlet. For instance: This help is showing how the different parameters can be used when calling the cmdlet. If you’ve never paid any attention to these, the notation can be difficult to work …

Continue reading ‘Deciphering PowerShell Syntax Help Expressions’ »

Specifying PowerShell Parameter Position

Positional Parameters Whether you know it or not, if you’ve used PowerShell, you’ve used positional parameters. In the following command the argument (c:\temp) is passed to the -Path parameter by position. The other option for passing a parameter would be to pass it by name like this: It makes sense for some commands to allow …

Continue reading ‘Specifying PowerShell Parameter Position’ »

PowerShell Parameter Disambiguation and a Surprise

When you’re learning PowerShell one of the first things you will notice is that you don’t have to use the full parameter name.  This is because of something called parameter disambiguation. When it works For instance, instead of saying Get-ChildItem -Recurse, you can say Get-ChildItem -R.  Get-ChildItem only has one (non-dynamic) parameter that started with the …

Continue reading ‘PowerShell Parameter Disambiguation and a Surprise’ »