mediumMultiple ChoiceObjective-mapped
220-1202 Practice Question: A technician is troubleshooting a PowerShell…
A technician is troubleshooting a PowerShell script that collects system information and writes it to a log file. The script runs without errors but the log file is empty. The script uses Out-File to write data. What is the most likely issue?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The command before Out-File does not produce any output.
If a PowerShell command does not produce output, piping it to Out-File will result in an empty file. The issue is that the command used does not generate any output.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The script is not running with administrative privileges.
Why it's wrong here
Writing a log file to the current working directory, or any directory within a user's profile (e.g., Documents, Desktop), typically does not require elevated administrative privileges. Standard user permissions are sufficient for creating and modifying files in these locations. Administrative rights are generally only necessary for operations affecting system-wide configurations, protected system directories like C:\Windows or Program Files, or modifying the registry. Therefore, a lack of administrative privileges would not cause an empty log file in a user-accessible location.
- ✗
The Out-File cmdlet is misspelled.
Why it's wrong here
If the Out-File cmdlet were misspelled, PowerShell's parser would typically generate an error indicating that the term or command could not be recognized. This would prevent the script from executing successfully and creating any file at all, rather than producing an empty one. The fact that an empty log file is created implies that the Out-File cmdlet was correctly identified and invoked by the PowerShell engine.
- ✓
The command before Out-File does not produce any output.
Why this is correct
The Out-File cmdlet functions by taking input from the PowerShell pipeline. If the command preceding Out-File (e.g., Get-Process -Name "NonExistentProcess") returns no objects or an empty collection, Out-File will still execute successfully. In this scenario, Out-File will create the specified log file but write zero bytes of content to it, resulting in an empty file. This is a common cause of empty output files when a filter or query yields no results.
- ✗
The log file path contains a forward slash instead of a backslash.
Why it's wrong here
PowerShell is highly flexible regarding path separators and correctly interprets both forward slashes (/) and backslashes (\) as valid directory delimiters in file paths. This cross-platform compatibility means that using a forward slash in a path, such as C:/Logs/script.log, would not cause any error or prevent Out-File from writing content to the file. Therefore, this path format would not result in an empty log file.
Go deeper
Related to this question
About these practice questions
One of 495 original 220-1202 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 220-1202 practice question is part of Courseiva's free CompTIA 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 220-1202 exam.