What areas of PowerShell do you struggle to learn?

Occasional Contributor

Are there areas of PowerShell that you find hard to understand or are confusing? post your answers as replies. 

5 Replies

Classes, the future of JEA @MikeKanakos 

I'm past this, thankfully, but it was really tough to "get good at" pipelines.

@MikeKanakos Not so much a struggle to learn about but a struggle to remember and not get caught by:

 

  • Select-string vs -match and then using the right form of $matches , $_.match and how to access match groups (slightly different for both)
  • Variable scoping in ForEach-Object loops that don't get reset so subsequent iterations keep giving the same data instead of $null for properties.  This is especially bad when performing file-based actions and expecting to be in a different directory and changing the wrong thing.

 

As to the ones I've seen over the years that trip people up or surprise them to have not learned about sooner:

  • Pipelines (how to use them / situations where storing to a variable instead has performance benefits)
  • The splat (@) operator 

 

@wo items that I know I'm not good at, and I bet a lot of others aren't good at either:

Foreach-Object and Select-Object without relying on any positional parameters.

Thanks for posting this, made me look at the syntax/overloads and realized I'd never seen or used the -MemberName -ArgumentList parameters (although was used to using explicit -begin/-end params.