What’s a PowerShell One-Liner & NOT a PowerShell One-Liner?

Lately, I’ve seen a few examples of commands that aren’t PowerShell one-liners being passed off as such by people in the PowerShell community who “should” know better. If I were interviewing someone who claimed to be a PowerShell expert with more than five years of experience, I would definitely ask these types of questions.

Example 1 – The following command is a PowerShell one-liner? (True or False)

Example 2 – The following command is a PowerShell one-liner? (True or False)

A PowerShell one-liner is one continuous pipeline and not necessarily a command that’s on one physical line. Not all commands that are on one physical line are PowerShell one-liners.

µ

2 Comments

  1. Blanke

    Absolutely right!

    Reply
  2. Mateusz Nadobnik

    Example 1 – false (The semicolon only helps write multiple commands on a single line)
    Example 2 – true

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: