PowerShell - String OperationsWhich of the following is the correct syntax to search for the word 'error' in a file named 'log.txt' using Select-String?ASelect-String -Pattern error -Path log.txtBSelect-String log.txt errorCSelect-String -File log.txt -Search errorDSelect-String -Find error -File log.txtCheck Answer
Step-by-Step SolutionSolution:Step 1: Recall Select-String parameter namesThe correct parameters are -Pattern for the search text and -Path for the file.Step 2: Match syntax with optionsSelect-String -Pattern error -Path log.txt uses -Pattern and -Path correctly; others use invalid parameters.Final Answer:Select-String -Pattern error -Path log.txt -> Option AQuick Check:Correct parameters = Select-String -Pattern error -Path log.txt [OK]Quick Trick: Use -Pattern for text and -Path for files [OK]Common Mistakes:Using incorrect parameter names like -File or -FindOmitting parameter names and causing errorsMixing order of parameters incorrectly
Master "String Operations" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Operators - Assignment operators - Quiz 14medium PowerShell Basics and Environment - PowerShell vs Bash vs CMD comparison - Quiz 2easy PowerShell Basics and Environment - PowerShell versions (5.1 vs 7+) - Quiz 8hard PowerShell Basics and Environment - First PowerShell command - Quiz 10hard String Operations - String interpolation (double quotes) - Quiz 13medium String Operations - String concatenation - Quiz 6medium String Operations - Why string manipulation is frequent - Quiz 14medium Variables and Data Types - Type casting - Quiz 9hard Variables and Data Types - Hash tables (dictionaries) - Quiz 8hard Variables and Data Types - Boolean values - Quiz 4medium