Detecting Encoded PowerShell Commands in Log Analytics
This SC-200 practice question tests your understanding of respond to security incidents. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
Exhibit
Refer to the exhibit.
```
$huntQuery = @"
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName == "powershell.exe"
| where ProcessCommandLine contains "-EncodedCommand"
| project Timestamp, DeviceName, AccountName, ProcessCommandLine
| take 1000
"@
$result = Invoke-AzOperationalInsightsQuery -WorkspaceId "..." -Query $huntQuery
```
Refer to the exhibit. A security analyst runs this PowerShell script to query a Log Analytics workspace. What is the purpose of this query?
Exhibit
Refer to the exhibit.
```
$huntQuery = @"
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName == "powershell.exe"
| where ProcessCommandLine contains "-EncodedCommand"
| project Timestamp, DeviceName, AccountName, ProcessCommandLine
| take 1000
"@
$result = Invoke-AzOperationalInsightsQuery -WorkspaceId "..." -Query $huntQuery
```
A
Count the number of unique devices
Why wrong: No aggregation is used.
B
Identify all PowerShell executions in the last 7 days
Why wrong: The query filters for encoded commands, not all PowerShell.
C
List all processes run by a specific account
Why wrong: No account filter is applied.
D
Detect suspicious PowerShell activity using encoded commands
The query specifically looks for '-EncodedCommand'.
E
Find devices that have not run PowerShell recently
Why wrong: It finds devices that did run PowerShell.
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Detect suspicious PowerShell activity using encoded commands
The PowerShell script uses the `| where {$_ -match 'powershell.*-enc'} ` filter to search for command lines containing 'powershell' followed by '-enc', which is the alias for the `-EncodedCommand` parameter. This parameter is commonly used by attackers to obfuscate malicious PowerShell commands by passing them as a Base64-encoded string. The query is specifically designed to detect suspicious PowerShell executions that use encoded commands, making option D correct.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
✗
Count the number of unique devices
Why it's wrong here
No aggregation is used.
✗
Identify all PowerShell executions in the last 7 days
Why it's wrong here
The query filters for encoded commands, not all PowerShell.
✗
List all processes run by a specific account
Why it's wrong here
No account filter is applied.
✓
Detect suspicious PowerShell activity using encoded commands
Why this is correct
The query specifically looks for '-EncodedCommand'.
Related concept
Read the scenario before looking for a memorised answer.
✗
Find devices that have not run PowerShell recently
Why it's wrong here
It finds devices that did run PowerShell.
Common exam traps
Common exam trap: answer the scenario, not the keyword
The SC-200 exam often tests the ability to recognize that the `-enc` parameter is a shorthand for `-EncodedCommand`, which is a key indicator of obfuscated PowerShell execution, and candidates may mistakenly think the query simply lists all PowerShell executions (option B) without noticing the specific filter.
Trap categories for this question
Command / output trap
The query filters for encoded commands, not all PowerShell.
Detailed technical explanation
How to think about this question
The `-EncodedCommand` parameter accepts a Base64-encoded string, which PowerShell decodes and executes. Attackers often use this to bypass simple string-based detection rules, as the encoded payload can be obfuscated. In a real-world scenario, a security analyst might extend this query to also look for other suspicious parameters like `-WindowStyle Hidden` or `-ExecutionPolicy Bypass` to catch more sophisticated attacks. The `$_.CommandLine` property is typically populated from Event ID 4688 (Process Creation) in Windows Security logs or from Sysmon Event ID 1.
KKey Concepts to Remember
Read the scenario before looking for a memorised answer.
Find the constraint that changes the correct option.
Eliminate answers that are true in general but not in this case.
TExam Day Tips
→Watch for words such as best, first, most likely and least administrative effort.
→Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A cloud solutions architect for a retail company is evaluating services for a new workload. The correct answer here reflects best practice for the specific scenario described — not a general cloud recommendation. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Cloud exam questions reward reading the constraint carefully: the same technology can be right or wrong depending on the use case.
Related glossary terms
Concepts from this question explained
These glossary pages explain the core terms tested in this SC-200 question in full detail.
Respond to security incidents — This question tests Respond to security incidents — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: Detect suspicious PowerShell activity using encoded commands — The PowerShell script uses the `| where {$_ -match 'powershell.*-enc'} ` filter to search for command lines containing 'powershell' followed by '-enc', which is the alias for the `-EncodedCommand` parameter. This parameter is commonly used by attackers to obfuscate malicious PowerShell commands by passing them as a Base64-encoded string. The query is specifically designed to detect suspicious PowerShell executions that use encoded commands, making option D correct.
What should I do if I get this SC-200 question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
This SC-200 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SC-200 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.