PowerShell - File and Directory OperationsWhich of the following is the correct syntax to append text to a file using Out-File?AOut-File -FilePath "log.txt" -InputObject "New entry" -AppendBOut-File -FilePath "log.txt" -InputObject "New entry"CSet-Content -Path "log.txt" -Value "New entry" -AppendDSet-Content -FilePath "log.txt" -InputObject "New entry"Check Answer
Step-by-Step SolutionSolution:Step 1: Identify append syntax for Out-FileOut-File uses the -Append parameter to add content without overwriting.Step 2: Check other optionsSet-Content does not support -Append; Out-File -FilePath "log.txt" -InputObject "New entry" -Append correctly uses Out-File with -Append.Final Answer:Out-File -FilePath "log.txt" -InputObject "New entry" -Append -> Option AQuick 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-FileMixing parameter names like -Value and -InputObject
Master "File and Directory Operations" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Error Handling - Why error handling prevents script failure - Quiz 12easy File and Directory Operations - CSV operations (Import-Csv, Export-Csv) - Quiz 5medium File and Directory Operations - JSON operations (ConvertFrom-Json, ConvertTo-Json) - Quiz 7medium File and Directory Operations - New-Item for creation - Quiz 8hard File and Directory Operations - Why file management is core to scripting - Quiz 2easy Functions - Default parameter values - Quiz 5medium Modules and Script Organization - Script modules vs binary modules - Quiz 6medium Modules and Script Organization - Module creation basics - Quiz 6medium Working with Objects - Object arrays - Quiz 5medium Working with Objects - Custom objects (PSCustomObject) - Quiz 7medium