Bird
0
0

What does the PowerShell command Set-Content do when used on a file?

easy📝 Conceptual Q11 of 15
PowerShell - File and Directory Operations
What does the PowerShell command Set-Content do when used on a file?
AIt writes new content to the file, replacing any existing content.
BIt appends new content to the end of the file without removing existing content.
CIt deletes the file from the system.
DIt reads the content of the file and displays it on the screen.
Step-by-Step Solution
Solution:
  1. Step 1: Understand Set-Content behavior

    Set-Content writes data to a file and replaces any existing content by default.
  2. Step 2: Compare with other commands

    Unlike Out-File with -Append, Set-Content does not append but overwrites.
  3. Final Answer:

    It writes new content to the file, replacing any existing content. -> Option A
  4. Quick Check:

    Set-Content replaces file content = D [OK]
Quick Trick: Set-Content replaces file content, Out-File can append [OK]
Common Mistakes:
  • Confusing Set-Content with appending behavior
  • Thinking Set-Content reads files
  • Assuming it deletes files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes