Bird
0
0

Which of the following is the correct syntax to read all lines from a file named log.txt using PowerShell?

easy📝 Syntax Q12 of 15
PowerShell - File and Directory Operations
Which of the following is the correct syntax to read all lines from a file named log.txt using PowerShell?
AGet-Content -Path log.txt
BGet-Content log.txt -ReadAll
CRead-File log.txt
DGet-FileContent log.txt
Step-by-Step Solution
Solution:
  1. Step 1: Recall the correct cmdlet and syntax

    The correct cmdlet to read file content is Get-Content with the -Path parameter specifying the file.
  2. Step 2: Evaluate the options

    Get-Content -Path log.txt uses correct syntax. Options A, C, and D use incorrect cmdlets or parameters that do not exist.
  3. Final Answer:

    Get-Content -Path log.txt -> Option A
  4. Quick Check:

    Correct cmdlet and parameter = Get-Content -Path log.txt [OK]
Quick Trick: Use Get-Content with -Path to specify file [OK]
Common Mistakes:
  • Using non-existent cmdlets like Read-File
  • Adding invalid parameters like -ReadAll
  • Confusing parameter order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes