Bird
0
0

What will be the result of running this PowerShell script?

medium📝 Command Output Q4 of 15
PowerShell - Automation Patterns
What will be the result of running this PowerShell script?
Get-EventLog -LogName System -EntryType Error | Select-Object -First 3 | Export-Csv -Path 'errors.csv' -NoTypeInformation; Get-Content 'errors.csv'
AAn error because Get-EventLog does not support Export-Csv
BA CSV file content listing the first 3 system error events
CAn empty file since no errors are selected
DOnly the headers of the CSV file without any data rows
Step-by-Step Solution
Solution:
  1. Step 1: Understand the pipeline

    Get-EventLog fetches system error events.
  2. Step 2: Select first 3 entries

    Select-Object -First 3 limits output to three events.
  3. Step 3: Export and read CSV

    Export-Csv saves data; Get-Content reads the CSV content.
  4. Final Answer:

    A CSV file content listing the first 3 system error events -> Option B
  5. Quick Check:

    Export-Csv outputs data; Get-Content displays it [OK]
Quick Trick: Export-Csv outputs data; Get-Content reads file [OK]
Common Mistakes:
  • Assuming Export-Csv cannot handle event log objects
  • Expecting no data if errors exist in the log

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes