Bird
0
0

You want to add the line "Update complete" to the end of the file status.log without removing existing content. Which command correctly appends the text?

medium📝 Debug Q7 of 15
PowerShell - File and Directory Operations
You want to add the line "Update complete" to the end of the file status.log without removing existing content. Which command correctly appends the text?
A"Update complete" | Out-File -FilePath status.log -Append
B"Update complete" | Set-Content -Path status.log
CSet-Content -Path status.log -Value "Update complete" -Append
DOut-File -FilePath status.log -Value "Update complete"
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct cmdlet for appending

    Set-Content overwrites by default and does not have an append parameter. Out-File supports the -Append switch.
  2. Step 2: Use Out-File with -Append

    Using Out-File with -Append adds the text to the end of the file without removing existing content.
  3. Final Answer:

    "Update complete" | Out-File -FilePath status.log -Append -> Option A
  4. Quick Check:

    Appending requires Out-File with -Append, not Set-Content [OK]
Quick Trick: Use Out-File -Append to add text without overwriting [OK]
Common Mistakes:
  • Using Set-Content expecting it to append
  • Trying to use -Append with Set-Content (not supported)
  • Using Out-File without -Append which overwrites

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes