Search test library by skills or roles
⌘ K

Adaface Sample PowerShell Questions

Here are some sample PowerShell questions from our premium questions library (10273 non-googleable questions).

Skills

🧐 Question

Medium

Dynamic Function Invocation
Dynamic Expressions
Array Manipulation
Function Invocation
Solve
You're tasked with dynamically invoking functions based on their names stored in an array. Additionally, you're required to filter out functions that have the term "Admin" in their name. Your colleague suggests the following approach:
 image
Assuming no other functions are defined in the session, which of the following will $results contain after executing the script?

Medium

Error Handling with Try-Catch-Finally
Error Handling
Exceptions
Script Flow
Solve
You're analyzing a script designed to interact with a remote API. The script fetches data, processes it, and then ensures that all temporary files are deleted. You come across the following code block:
 image
After a successful data fetch, the script occasionally throws the custom error. When this happens, what will be the output and state of the system?
A: The output will display "Network error
            B: The output will display "General error
            C: The script will exit without any output due to the custom error, but the temporary file will be deleted.
            D: The output will display "General error
            E: The script will terminate prematurely, not executing the finally block.

Hard

Execution Policy Bypass
Execution Policy
Security
Script Invocation
Solve
A server you are working on has the PowerShell execution policy set to "Restricted", preventing scripts from running. You need to execute a script named "Deploy.ps1". You recall a technique to bypass the execution policy without changing it permanently. Which of the following methods would allow you to run "Deploy.ps1" without permanently altering the execution policy?
A: Set-ExecutionPolicy Unrestricted -Scope Process; .\Deploy.ps1
            B: PowerShell -ExecutionPolicy Bypass -File .\Deploy.ps1
            C: Invoke-Command -ScriptBlock { .\Deploy.ps1 }
            D: Start-Process PowerShell -ArgumentList "-ExecutionPolicy Unrestricted", "-File .\Deploy.ps1"
            E: Import-Module .\Deploy.ps1

Medium

Logging with Transcript
Logging
Transcription
Error Handling
Solve
You're reviewing a script designed to automate server maintenance tasks. One requirement is to log every action and potential error for auditing purposes. The script utilizes Start-Transcript and Stop-Transcript cmdlets to capture the session. Here's a snippet:
 image
After several successful runs, you notice that some logs are missing crucial information regarding errors. Which of the following could be a reason for the missing error details?
A: The -Append parameter is causing overwritten logs.
            B: Not all errors are displayed in the console, hence not captured by the transcript.
            C: The Stop-Transcript cmdlet needs to be invoked with an -ErrorAction Continue parameter.
            D: Transcription only captures standard output, not error streams.
            E: The log file path should be specified again in Stop-Transcript.

Medium

Nested Runspaces
Runspaces
Variable Scoping
Concurrency
Solve
You're optimizing a script for performance by leveraging runspaces to execute tasks concurrently. Each runspace is supposed to increment a shared counter object. Here's your setup:
 image
You expect the $global:counter to be 5 after all runspaces complete. However, it's not consistently reaching that value. What's the most probable reason for this behavior?
A: Runspaces can't access global variables.
            B: The counter increment operation is not thread-safe, leading to race conditions.
            C: The runspace pool size is limiting the number of concurrent operations.
            D: The $global:counter initialization should be inside the script block.
            E: The runspace pool's Close and Dispose methods are prematurely terminating the runspaces.
🧐 Question🔧 Skill

Medium

Dynamic Function Invocation
Dynamic Expressions
Array Manipulation
Function Invocation

2 mins

PowerShell
Solve

Medium

Error Handling with Try-Catch-Finally
Error Handling
Exceptions
Script Flow

2 mins

PowerShell
Solve

Hard

Execution Policy Bypass
Execution Policy
Security
Script Invocation

3 mins

PowerShell
Solve

Medium

Logging with Transcript
Logging
Transcription
Error Handling

2 mins

PowerShell
Solve

Medium

Nested Runspaces
Runspaces
Variable Scoping
Concurrency

3 mins

PowerShell
Solve
🧐 Question🔧 Skill💪 Difficulty⌛ Time
Dynamic Function Invocation
Dynamic Expressions
Array Manipulation
Function Invocation
PowerShell
Medium2 mins
Solve
Error Handling with Try-Catch-Finally
Error Handling
Exceptions
Script Flow
PowerShell
Medium2 mins
Solve
Execution Policy Bypass
Execution Policy
Security
Script Invocation
PowerShell
Hard3 mins
Solve
Logging with Transcript
Logging
Transcription
Error Handling
PowerShell
Medium2 mins
Solve
Nested Runspaces
Runspaces
Variable Scoping
Concurrency
PowerShell
Medium3 mins
Solve

Trusted by recruitment teams in enterprises globally

Amazon Morgan Stanley Vodafone United Nations HCL PayPal Bosch WeWork Optimum Solutions Deloitte Microsoft NCS Doubtnut Sokrati J&T Express Capegemini

We evaluated several of their competitors and found Adaface to be the most compelling. Great library of questions that are designed to test for fit rather than memorization of algorithms.


Swayam Narain, CTO, Affable

hashtag image heart icon Swayam
customers across world
Join 1500+ companies in 80+ countries.
Try the most candidate friendly skills assessment tool today.
g2 badges
Ready to streamline your recruitment efforts with Adaface?
Ready to streamline your recruitment efforts with Adaface?
logo
40 min tests.
No trick questions.
Accurate shortlisting.
ada
Ada
● Online
Previous
Score: NA
Next
✖️