Find specific String in Textfile - Powershell
问题 I know this question might be a "new guy question" but I probably made a logical mistake. I have a text file and I want to search if it contains a string or not. I tried it as shown below but it doesn't work: $SEL = "Select-String -Path C:\Temp\File.txt -Pattern Test" if ($SEL -eq $null) { echo Contains String } else { echo Not Contains String } 回答1: i think this is what you are trying to do: $SEL = Select-String -Path C:\Temp\File.txt -Pattern "Test" if ($SEL -ne $null) { echo Contains