---
title: "PowerShell: Windows Scripting Fundamentals"
description: "Test your knowledge of PowerShell fundamentals with this comprehensive quiz covering cmdlets, pipelines, objects, variables, execution policies, functions, scripting best practices, and Windows automation."
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/quizzes/post/powershell-scripting-fundamentals-quiz
---

# PowerShell: Windows Scripting Fundamentals

Welcome to the PowerShell Basics Quiz! This quiz is designed to test your understanding of fundamental PowerShell concepts, cmdlets, and scripting best practices. Each question is multiple-choice, and you'll find hints to help you along the way. Good luck!

## Questions

### 1. What is the standard Verb-Noun naming convention in PowerShell?

- `Action.Object`
  - This dot-notation is typically used to access object properties or methods rather than naming cmdlets.
- **`Verb-Noun`** ✅
  - PowerShell uses this hyphenated structure to make commands predictable and easy for users to discover.
- `Command_Option`
  - This underscore-based naming is common in other scripting languages but is not the standard for cmdlets.
- `Noun-Verb`
  - Reversing the order is invalid; PowerShell requires the action verb to precede the target noun.

**Hint:** Think of a specific action applied to a specific object.

### 2. How do you define a variable in PowerShell?

- `var Name = "Value"`
  - The "var" keyword is standard in languages like C# or JavaScript but is not used for PowerShell assignments.
- **`$Name = "Value"`** ✅
  - PowerShell uses the dollar sign prefix to identify variables, allowing them to store strings or complex objects.
- `set Name = "Value"`
  - This is the legacy syntax used in the Windows Command Prompt (CMD) rather than the modern PowerShell environment.
- `@Name = "Value"`
  - The @ symbol is reserved for defining arrays and hash tables or for splatting parameters into commands.

**Hint:** Use the character associated with "Strings" and "Money".

### 3. What is the primary difference between the Bash pipe and the PowerShell pipe?

- PowerShell pipes only support Windows-based binary data
  - PowerShell pipes are cross-platform and handle .NET objects, not just Windows-specific binary formats.
- **Bash passes text strings, while PowerShell passes .NET Objects** ✅
  - Passing objects allows you to access properties directly without needing to parse text with grep or awk.
- Bash pipes can handle larger files than PowerShell pipes
  - Both shells can handle large data streams; the difference lies in the structure of the data being transmitted.
- PowerShell pipes require manual data type conversion
  - PowerShell handles object types automatically within the pipeline, making manual conversion largely unnecessary.

**Hint:** One passes text; the other passes "living" data.

### 4. Which cmdlet is used to filter objects based on specific criteria?

- `Select-Object`
  - Select-Object is primarily used to choose specific properties or rows, not to evaluate logical conditions.
- **`Where-Object`** ✅
  - This cmdlet evaluates each object in the pipeline against a script block to determine if it should remain.
- `Filter-Item`
  - While "Filter" is a valid concept, the standard cmdlet for conditional pipeline filtering is Where-Object.
- `Match-Property`
  - This is not a native PowerShell cmdlet; matching is usually performed within a Where-Object script block.

**Hint:** Think: "Find items WHERE this condition is true".

### 5. What does the automatic variable "$_" represent?

- The result of the last failed system operation
  - System errors are stored in the $Error global variable rather than the pipeline iteration variable.
- **The current object being processed in the pipeline** ✅
  - This variable allows you to reference properties of the item currently moving through a loop or filter.
- The exit code of the most recent console command
  - PowerShell tracks exit codes in $LASTEXITCODE, which is distinct from the pipeline object variable.
- The total count of items residing in a collection
  - To find the count of items, you would typically use the .Count property on an array or collection variable.

**Hint:** It refers to the "Current" thing in the pipe.

### 6. Which comparison operator is used for "Not Equal"?

- `!=`
  - While used in C-style languages, PowerShell requires hyphenated text operators for its comparison logic.
- **`-ne`** ✅
  - The -ne operator stands for "Not Equal" and is the standard way to compare two values for inequality.
- `-not`
  - The -not operator is a logical toggle that reverses a Boolean value rather than comparing two distinct items.
- `-isnot`
  - This operator is used to verify if an object is NOT a specific data type rather than comparing its value.

**Hint:** PowerShell uses text-based operators prefixed with a hyphen.

### 7. What is the purpose of the "Get-Member" cmdlet?

- To list members of an Active Directory group
  - Active Directory management requires specific cmdlets like Get-ADGroupMember rather than Get-Member.
- **To see the properties and methods available for an object** ✅
  - This cmdlet is essential for discovering the structure of an object and what actions you can perform on it.
- To add a new member variable to a custom object
  - Adding properties is handled by the Add-Member cmdlet; Get-Member is strictly for inspection and discovery.
- To check the version of the PowerShell host
  - Host version information is typically retrieved via $PSVersionTable or the Get-Host cmdlet.

**Hint:** It "unwraps" an object to show you its properties and methods.

### 8. How do you check the execution policy of your system?

- `policy --status`
  - This command structure follows a Linux-style syntax that is not recognized by the PowerShell engine.
- **`Get-ExecutionPolicy`** ✅
  - This cmdlet returns the current safety level that determines which types of scripts are allowed to run.
- `Set-ExecutionPolicy`
  - This cmdlet is used to modify or update the current policy rather than simply viewing its status.
- `Show-ScriptPolicy`
  - This is not a native cmdlet; viewing configurations in PowerShell almost always uses the "Get" verb.

**Hint:** You want to "Get" the "ExecutionPolicy".

### 9. What does the "RemoteSigned" execution policy mean?

- All scripts must be signed by a globally trusted CA
  - Requiring all scripts to be signed describes the AllSigned policy, which is more restrictive than RemoteSigned.
- **Allows local scripts to run while requiring signatures for downloaded files** ✅
  - This policy provides a balance by trusting local files while verifying the identity of files from the web.
- Prevents all scripts from running regardless of origin
  - This describes the Restricted policy, which is often the default setting for Windows client workstations.
- Permits any script to execute without any security checks
  - This describes the Bypass or Unrestricted policies, which offer no protection against untrusted code.

**Hint:** It treats local and downloaded scripts differently.

### 10. What is a Hash Table in PowerShell?

- A sequential array of numeric data points
  - Standard arrays store items in a sequence; hash tables use specific names or keys to organize data.
- **A data structure used to store unique keys and values** ✅
  - Defined with the @{ } syntax, hash tables are ideal for organizing data into searchable name-value pairs.
- A method for encrypting sensitive script files
  - While hashing is an encryption concept, a hash table is simply a way to structure data in memory.
- A relational table stored within a database
  - Hash tables exist in RAM during the session; database tables are persistent structures stored on disk.

**Hint:** A collection of Key-Value pairs.

### 11. How do you bypass a confirmation prompt when running a risky command?

- `-Suppress`
  - This is not a standard PowerShell parameter; suppression is usually handled via Confirm or Force.
- **`-Force`** ✅
  - The -Force parameter overrides prompts and minor safety restrictions to complete an action immediately.
- `-YesToAll`
  - This is a response provided during an interactive prompt rather than a parameter used to bypass it.
- `-Silent`
  - While used in installers, PowerShell cmdlets typically use -Force or -ErrorAction to manage prompts.

**Hint:** Think "Force".

### 12. Which cmdlet is used to output text to the console with color options?

- `Write-Output`
  - Write-Output sends data into the pipeline for further processing but does not support color formatting.
- **`Write-Host`** ✅
  - This cmdlet interacts directly with the console window and supports parameters like -ForegroundColor.
- `Out-Console`
  - This is not a valid cmdlet; PowerShell uses the "Write" verb for terminal-bound text operations.
- `New-Message`
  - This cmdlet does not exist in the core engine; standard terminal output is managed by Write-Host.

**Hint:** You are "Writing" to the "Host".

### 13. What is "Splatting"?

- Removing all empty files from a directory
  - Cleanup tasks are unrelated to splatting, which is a method for parameter passing in a cmdlet.
- **Bundles command parameters into a single variable for easier execution** ✅
  - By using a hash table and the @ symbol, you can pass multiple arguments to a command in a clean way.
- Formatting a string by joining multiple values
  - Joining strings is referred to as concatenation; splatting specifically involves command arguments.
- Separating a complex object into individual variables
  - This is often called destructuring or splitting; splatting refers to the bundling of parameters.

**Hint:** Using a Hash Table to pass many parameters to a command at once.

### 14. What is the purpose of the "Get-Help" cmdlet?

- To perform an online search for shell errors
  - While it can link to online pages, Get-Help primarily serves to display local cmdlet documentation.
- **To display documentation and examples for PowerShell commands** ✅
  - This tool is the primary way to learn about cmdlet parameters, syntax, and usage examples.
- To open a support ticket with the system vendor
  - PowerShell documentation tools do not facilitate live support or ticket creation with vendors.
- To automatically debug errors in a script file
  - Debugging is a separate process; Get-Help only provides the static documentation for using cmdlets.

**Hint:** The built-in documentation system.

### 15. Which symbol is used for comments in PowerShell?

- `//`
  - This syntax is common in C-style languages but is not recognized by the PowerShell interpreter.
- **`#`** ✅
  - The hash symbol is used for single-line comments, while <# #> is used for multi-line blocks.
- `--`
  - This is the standard comment syntax for SQL and is not used for PowerShell scripting.
- `/*`
  - PowerShell uses a different bracket-based syntax for multi-line comments (<# and #>).

**Hint:** The same symbol used for hashtags.

### 16. What happens when you use the "Export-Csv" cmdlet?

- It creates a log of the current command history
  - Command history is exported using Export-History; Export-Csv is used for object data mapping.
- **It saves PowerShell objects into a Comma Separated Values file** ✅
  - This cmdlet takes the properties of an object and converts them into rows and columns in a text file.
- It converts the session variables into a binary file
  - Binary serialization is handled by other cmdlets; Export-Csv produces human-readable text.
- It sends the current object to a remote web server
  - Sending data to web servers typically requires Invoke-RestMethod or Invoke-WebRequest.

**Hint:** It converts objects into a spreadsheet-ready format.

### 17. How do you specify a data type for a variable (e.g., an Integer)?

- **`[int]$Number = 5`** ✅
  - Using square brackets before a variable name is called type casting, which enforces a specific data type.
- `$Number:int = 5`
  - This syntax is used in languages like Python or TypeScript but is not valid in PowerShell.
- `int $Number = 5`
  - Declaring types without brackets is standard in C++ or Java but is not recognized by PowerShell.
- `$Number = 5 (int)`
  - PowerShell requires the type cast to be placed before the variable or value, not at the end of the line.

**Hint:** Use square brackets before the variable name.

### 18. What does the "Test-Path" cmdlet do?

- It creates a new directory if one is missing
  - Creating directories requires New-Item; Test-Path only verifies if a location already exists.
- **It checks if a file or folder exists at a specific location** ✅
  - This cmdlet returns a Boolean (True/False) result, making it ideal for use in conditional logic.
- It verifies the integrity of a system binary file
  - Integrity checks usually involve Get-FileHash; Test-Path only confirms existence, not file health.
- It measures the latency to a specific network path
  - Network latency is measured using Test-NetConnection or ping rather than the Test-Path cmdlet.

**Hint:** It returns a simple True or False.

### 19. Which cmdlet is used to download content from the web?

- `Get-WebContent`
  - This is not a native cmdlet; PowerShell uses the "Invoke" verb for active web interactions.
- **`Invoke-WebRequest`** ✅
  - This cmdlet is the primary tool for downloading files or retrieving raw HTML from web addresses.
- `Download-File`
  - While descriptive, "Download" is not an approved PowerShell verb for the core command set.
- `Fetch-URL`
  - This command does not exist in PowerShell; URL data retrieval is handled by Invoke-WebRequest.

**Hint:** You "Invoke" a "WebRequest".

### 20. What is the "Pipeline" symbol in PowerShell?

- `>`
  - The greater-than symbol is used for output redirection to a file rather than piping between commands.
- **`|`** ✅
  - The pipe symbol allows the output object of one cmdlet to be used as the input for the next.
- `&`
  - The ampersand is the call operator used to execute scripts or commands stored within variables.
- `%`
  - The percent sign is an alias for ForEach-Object and is not the symbol for the pipeline itself.

**Hint:** The vertical bar.

### 21. What is a "Script Block" in PowerShell?

- A security mechanism that prevents unauthorized code execution
  - Security is managed by the execution policy; script blocks are purely a code organization tool.
- **A collection of statements that acts as a single functional unit** ✅
  - Enclosed in curly braces, these blocks allow you to pass executable code as a parameter or variable.
- A storage container for pre-compiled binary library references
  - Libraries are typically handled by modules (.psm1); script blocks remain as interpreted code.
- A temporary file used to store script execution logs
  - Logging is handled by redirection or Transcript cmdlets; script blocks exist only in code or memory.

**Hint:** Code contained inside curly braces { }.

### 22. What is the purpose of the "-WhatIf" parameter?

- To prompt the user for confirmation before every action
  - Prompting for confirmation is the role of -Confirm; -WhatIf simulates the action instead.
- **To describe what a command would do without actually performing it** ✅
  - This safety feature allows administrators to see the impact of a command before committing to it.
- To provide a list of alternative cmdlets for a task
  - PowerShell does not suggest alternatives via -WhatIf; it only models the current command.
- To check if a script contains any structural syntax errors
  - Syntax errors are caught by the parser; -WhatIf checks the logical outcome of valid commands.

**Hint:** It is the "Dry Run" mode.

### 23. Which cmdlet is used to restart a computer?

- `Stop-Computer`
  - This cmdlet initiates a full shutdown of the system without performing a subsequent reboot.
- **`Restart-Computer`** ✅
  - This cmdlet is the standard way to reboot local or remote Windows systems via the shell.
- `Reset-System`
  - Reset-System is not a core cmdlet; PowerShell uses the approved verb "Restart" for reboots.
- `New-Reboot`
  - The "New" verb is for resource creation; "Restart" is the correct verb for cycling power.

**Hint:** Verb is "Restart", Noun is "Computer".

### 24. How do you create a new empty file in PowerShell?

- `Make-File filename.txt`
  - Make is not a standard PowerShell verb; the shell uses the New-Item cmdlet for this purpose.
- **`New-Item -Path "filename.txt" -ItemType File`** ✅
  - This cmdlet can create various items; you must specify the type as "File" for a text document.
- `Create-Item filename.txt`
  - While intuitive, "Create" is not an approved verb; "New" is used for creating all system items.
- `Set-Content filename.txt`
  - Set-Content is used to write data into a file; it is not the primary way to create a blank file.

**Hint:** "New" + "Item".

### 25. What does the cmdlet "Get-Process" return?

- A list of all software installed on the hard drive
  - Installed software is inventoried using Get-Package or Get-WmiObject rather than Get-Process.
- **Objects representing the programs currently running on the system** ✅
  - This returns live objects that can be filtered, sorted, or passed to Stop-Process to kill a task.
- A report on the health of the system CPU and RAM
  - While related, health monitoring usually requires Get-Counter or specific performance cmdlets.
- A chronological log of every command run in the shell
  - Command history is managed by the Get-History cmdlet rather than the process management tools.

**Hint:** A list of "living" items on the computer.

### 26. How do you access the first item in an array named $List?

- `$List[1]`
  - In zero-indexed languages, index [1] refers to the second item in the collection.
- **`$List[0]`** ✅
  - PowerShell starts counting collection items at zero, making [0] the first element.
- `$List.First()`
  - While used in LINQ or other languages, standard array access in PowerShell uses square brackets.
- `$List{0}`
  - Curly braces are reserved for script blocks and expansion, not for accessing array elements.

**Hint:** PowerShell is zero-indexed.

### 27. What is "PowerShell Core"?

- A legacy version designed for older Windows systems
  - Older systems use Windows PowerShell 5.1; Core is the modern, cross-platform successor.
- **The cross-platform version of PowerShell built on .NET Core** ✅
  - This version allows PowerShell scripts to run natively on Windows, Linux, and macOS environments.
- A high-performance version restricted to server hardware
  - PowerShell Core is available for all hardware tiers, including desktops, servers, and IoT devices.
- A cloud-only version used exclusively in Microsoft Azure
  - While used in Azure, Core is a standalone product that can be installed on any local machine.

**Hint:** The version that runs on Mac and Linux.

### 28. Which cmdlet is used to rename a file?

- `Move-Item`
  - While moving a file to a new name works, the dedicated command for renaming is Rename-Item.
- **`Rename-Item`** ✅
  - This cmdlet specifically changes the name of a file or directory without moving its location.
- `Change-Name`
  - Change is not an approved PowerShell verb; renaming tasks always use the "Rename" verb.
- `Set-Filename`
  - This cmdlet does not exist; file property changes are handled via Rename-Item or Set-Item.

**Hint:** Verb is "Rename", Noun is "Item".

### 29. What does "Invoke-Expression" do?

- It validates that a mathematical equation is true
  - Validation is handled by comparison operators; Invoke-Expression is for executing strings.
- **It evaluates and runs a string as a PowerShell command** ✅
  - This cmdlet allows you to build commands as strings and then run them dynamically as code.
- It removes a variable from the current shell memory
  - Removing variables is the task of Remove-Variable; Invoke-Expression is purely for execution.
- It converts a numeric value into a string data type
  - Type conversion is handled by casting or the .ToString() method rather than this cmdlet.

**Hint:** It runs a string as if it were code.

### 30. Which cmdlet is used to find the version of PowerShell?

- `Get-PowerShellVersion`
  - This is not a native cmdlet; versioning is primarily handled through a system variable.
- **`$PSVersionTable`** ✅
  - This automatic variable contains a hash table with details about the engine and shell version.
- `Check-Host`
  - Check-Host is not a valid cmdlet; versioning is viewed through Get-Host or $PSVersionTable.
- `Show-Version`
  - This command does not exist in the core engine; version checks are done via system variables.

**Hint:** Actually, it is a variable table.
