Bird
0
0

Which of the following is the correct syntax to append text to a file using Out-File?

easy📝 Syntax Q12 of 15
PowerShell - File and Directory Operations
Which of the following is the correct syntax to append text to a file using Out-File?
AOut-File -FilePath "log.txt" -InputObject "New entry" -Append
BOut-File -FilePath "log.txt" -InputObject "New entry"
CSet-Content -Path "log.txt" -Value "New entry" -Append
DSet-Content -FilePath "log.txt" -InputObject "New entry"
Step-by-Step Solution
Solution:
  1. Step 1: Identify append syntax for Out-File

    Out-File uses the -Append parameter to add content without overwriting.
  2. Step 2: Check other options

    Set-Content does not support -Append; Out-File -FilePath "log.txt" -InputObject "New entry" -Append correctly uses Out-File with -Append.
  3. Final Answer:

    Out-File -FilePath "log.txt" -InputObject "New entry" -Append -> Option A
  4. Quick Check:

    Out-File append needs -Append flag = A [OK]
Quick Trick: Use -Append with Out-File to add content, not Set-Content [OK]
Common Mistakes:
  • Using -Append with Set-Content (unsupported)
  • Omitting -Append when appending with Out-File
  • Mixing parameter names like -Value and -InputObject

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes