jypi
ExploreChatWays to LearnAbout

jypi

  • About Us
  • Our Mission
  • Team
  • Careers

Resources

  • Ways to Learn
  • Blog
  • Help Center
  • Community Guidelines
  • Contributor Guide

Legal

  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • Content Policy

Connect

  • Twitter
  • Discord
  • Instagram
  • Contact Us
jypi

© 2026 jypi. All rights reserved.

Courses/System Scripting/Evaluation 1: Integrated Assessment of Modules 1–6

Evaluation 1: Integrated Assessment of Modules 1–6

9 views

Consolidate learning with quizzes, labs, mini-projects, feedback, and remediation covering PowerShell and Python scripting basics.

Content

1 of 15

PowerShell Fundamentals Quiz

The No-Chill PowerShell Fundamentals Quiz (With Explanations)
5 views
intermediate
humorous
narrative-driven
science
gpt-5
5 views

Versions:

The No-Chill PowerShell Fundamentals Quiz (With Explanations)

Chapter Study

PowerShell Fundamentals Quiz: the object pipeline strikes back

You already built slick Python CLIs, parsed args like a boss, and automated routine tasks without breaking a sweat. Now it's time to flex those muscles in PowerShell, where the pipeline carries objects, not vibes. Well, vibes too.

This is an integrated check-in for Modules 1–6. Think of it as: what would happen if your Python automation brain took a weekend trip to PowerShell Land and came back with stories.


From Python to PowerShell: the mental shift you actually need

  • Python CLI: argparse + functions + modules + return values
  • PowerShell CLI: Param block + cmdlets + modules + output objects
Idea Python world PowerShell world
Get help pydoc, --help Get-Help, -Online, -Examples
Pipelines text streams object streams
CLI params argparse flags Param(...) with types, attributes
Packaging entry points functions, scripts, modules (.psm1)
Errors exceptions (try/except) terminating vs non-terminating, try/catch

Key upgrade: PowerShell passes .NET objects between commands. That means far less parsing and far more 'just use the property, king'.


How this works

  • 14 questions across multiple choice, short answer, and tiny hands-on tasks
  • Answer key with quick explanations at the end
  • A tiny bit of chaos sprinkled in, because growth is uncomfortable

Multiple choice (select one unless noted)

  1. Which cmdlet name follows PowerShell's standard naming convention?
  • A) list_processes
  • B) Get-Process
  • C) fetchProcess()
  • D) Process.Get()
  1. In the PowerShell pipeline, what is actually passed between commands by default?
  • A) Text lines
  • B) JSON strings
  • C) Objects
  • D) CSV records
  1. You want usage examples for Get-Content without opening a browser. Which command?
  • A) man Get-Content
  • B) Get-Command Get-Content -Examples
  • C) Get-Help Get-Content -Examples
  • D) Get-Help Get-Content | Select-Object Examples
  1. Which one-liner lists stopped services that start with 'Win', showing only Name and Status, sorted by Name?
  • A) Get-Service 'Win*' | Select-Object Name, Status | Sort-Object Name | Where-Object Status -eq Stopped
  • B) Get-Service Win* | Where-Object Status -eq 'Stopped' | Select-Object Name, Status | Sort-Object Name
  • C) Get-Service Win* | Sort-Object Name | Select-Object Name, Status -FilterScript { $_.Status -eq 'Stopped' }
  • D) Get-Service | Where-Object Name -like 'Win*' -and Status -eq Stopped | Select-Object Name, Status | Sort Name
  1. You run:
$procs = Get-Process | Select-Object Name, Id
$procs | Stop-Process

What magic makes this work?

  • A) Pipeline type conversion
  • B) Parameter binding by property name
  • C) Implicit method invocation
  • D) Reflection-based coercion
  1. You want to run a local script one time without permanently changing system policy. Which is valid on Windows PowerShell?
  • A) powershell -ExecutionPolicy Bypass -File .\script.ps1
  • B) pwsh -executionpolicy Strict -File ./script.ps1
  • C) Set-ExecutionPolicy Bypass; .\script.ps1; Set-ExecutionPolicy Default
  • D) Unblock-File .\script.ps1; .\script.ps1 (no policy involved)
  1. Which pair is the PowerShell twin of Python's argparse for named parameters?
  • A) Param(...) + [CmdletBinding()]
  • B) Begin{} + End{}
  • C) Set-Variable + Get-Variable
  • D) Function + Return
  1. Which command runs on two remote computers and gets the Spooler service?
  • A) Enter-PSSession -ComputerName A,B { Get-Service Spooler }
  • B) Invoke-Command -ComputerName A,B -ScriptBlock { Get-Service -Name Spooler }
  • C) Get-Service -ComputerName A,B Spooler
  • D) ssh A,B 'Get-Service Spooler'
  1. Which redirects only error output to a file while showing normal output on screen?
  • A) Get-ChildItem Foo > errors.txt
  • B) Get-ChildItem Foo 2> errors.txt
  • C) Get-ChildItem Foo *> errors.txt
  • D) Get-ChildItem Foo 1> errors.txt
  1. Which pipeline will correctly export process info to CSV with properties intact?
  • A) Get-Process | Format-Table Name, Id | Export-Csv procs.csv -NoTypeInformation
  • B) Get-Process | Select-Object Name, Id | Export-Csv procs.csv -NoTypeInformation
  • C) Get-Process | Out-String | Export-Csv procs.csv -NoTypeInformation
  • D) Get-Process | Format-List * | Export-Csv procs.csv -NoTypeInformation

Short answer and tiny builds

  1. Write a one-liner that:
  • Gets all running processes
  • Sorts by CPU descending
  • Shows the top 5 with Name, Id, CPU

Hint: Select-Object -First

  1. You're porting a Python CLI to PowerShell. Write a function header that:
  • Supports named parameters ComputerName (string, mandatory), and Force (switch)
  • Plays nicely with -WhatIf and -Confirm like a real cmdlet

You only need the signature and the first line.

  1. Explain in one sentence why Format-Table early in the pipeline breaks later processing like Export-Csv.

  2. Cross-platform brain check: What binary launches modern cross-platform PowerShell, and what behavior should you expect for execution policy on Linux?

  • Answer format: binary name; execution policy note

Fix this script (spot the gremlins)

You're trying to write an advanced function that stops a service by name, with -WhatIf support and friendly validation.

function Stop-NiceService {
    [CmdletBinding(SupportsShouldProcess=$true)]
    Param(
        [Parameter(Mandatory=$true)]
        [ValidateSet('Spooler','BITS','wuauserv')]
        [string]$Name
    )

    if ($PSCmdlet.ShouldProcess('service', 'stop')) {
        Get-Service -Name $name | Stop-Service -Force -Confirm
    }
}
  • Identify two improvements or fixes to make this more correct and user-friendly.

Pro tip: Think about ShouldProcess targets, pipeline input, and confirmation noise.


Why this matters (aka the automation glow-up)

Remember how you packaged Python scripts as CLIs? In PowerShell, your Param block is your argparse, comment-based help is your man page, and the output is object gold that plays nicely with every other cmdlet. Your routine tasks get shorter, safer, and less parse-y.

The secret handshake: Select for data, Format for display. Use -WhatIf before -Force. And never forget Get-Help exists.


Answer key with quick explains

  1. B. Verb-Noun is the law. Get-Process is correct.

  2. C. PowerShell passes objects. Parsing text is so last semester.

  3. C. Get-Help ... -Examples prints curated inline examples.

  4. B. Filter early, select properties, then sort. The order matters.

  5. B. Pipeline binding by property name wires Id to -Id. Chef's kiss.

  6. A. This runs the script with a temporary bypass. D can help but doesn't guarantee policy.

  7. A. Param with CmdletBinding gives you real cmdlet behavior, including common parameters.

  8. B. Invoke-Command fans out the scriptblock to remote machines.

  9. B. 2> sends only the error stream to a file. Streams are numbered.

  10. B. Select preserves objects; Format turns them into formatting data (aka 'display-only soup').

  11. One good answer:

Get-Process | Sort-Object CPU -Descending | Select-Object Name, Id, CPU -First 5
  • Sort first, then select the top N with the properties you want.
  1. One good answer:
function Invoke-Thing {
    [CmdletBinding(SupportsShouldProcess=$true)]
    Param(
        [Parameter(Mandatory=$true)] [string]$ComputerName,
        [switch]$Force
    )
    # ...
}
  • CmdletBinding unlocks -WhatIf and -Confirm. Switch is the idiomatic boolean flag.
  1. Format-Table converts objects into formatting instructions and strings, so downstream cmdlets lose real properties to work with.

  2. Answer: pwsh; on Linux, execution policy is not enforced the same way and generally doesn't block script execution (it is advisory or ignored).

Fixes for Stop-NiceService:

  • Use a precise ShouldProcess target, e.g. ShouldProcess($Name, 'Stop-Service') so -WhatIf prints meaningful messages.
  • Avoid redundant -Confirm when you already support ShouldProcess; let the user opt into -Confirm.
  • Consider pipeline input and property binding:
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true)]
[string]$Name
  • Respect errors with -ErrorAction Stop inside try/catch if you want terminating behavior.

Example improved snippet:

function Stop-NiceService {
    [CmdletBinding(SupportsShouldProcess=$true)]
    Param(
        [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
        [ValidateSet('Spooler','BITS','wuauserv')]
        [string]$Name
    )
    process {
        if ($PSCmdlet.ShouldProcess($Name, 'Stop-Service')) {
            Get-Service -Name $Name | Stop-Service -Force
        }
    }
}

Final takeaways

  • PowerShell pipelines are Lego for objects; stop whittling strings when you can just grab properties.
  • Param + CmdletBinding is your argparse energy. Add comment-based help to be a good citizen.
  • Select for data, Format for display. Keep formatting at the end.
  • Use -WhatIf like a safety harness and embrace remoting for scale.

Now go automate something delightfully boring. Your future self (and your logs) will thank you.

0 comments
Flashcards
Mind Map
Speed Challenge

Comments (0)

Please sign in to leave a comment.

No comments yet. Be the first to comment!

Ready to practice?

Sign up now to study with flashcards, practice questions, and more — and track your progress on this topic.

Study with flashcards, timelines, and more
Earn certificates for completed courses
Bookmark content for later reference
Track your progress across all topics