


How about this approach? $searchWords = ($sw in $searchWords)

ps1 file.It's critical that if you are new, that you first spend the time to ramp up to prevent a lot of unnecessary frustration and confusion you are going to encounter.ĭo a search on Microsoft Virtual Academy on PowerShell and YouTube for no cost video training. To run the script, create a file called Servers.txt, populate it with server names, save the code given above to a. $x = $host.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown,AllowCtrlC”) Write-host “Press any key to check next server” $Xer1 = $config | Select-String “DatabaseMaxCacheSize” $Wer1 = $config | Select-String “DatabaseCheckPointDepthMax” $Ver1 = $config | Select-String “EnableResourceMonitoring” $config = get-content “\\$CSrv\D$\Program Files\Microsoft\Exchange Server\Bin\” It basically searches for the string in the file, compares it with a standard value and returns a ‘Match’ or ‘No match’ according to what it found. Another Select-String parameter that you might find useful is -casesensitive, which performs a case-sensitive search.įollowing is a crude script I wrote to find the existence of three strings in file on multiple Hub transport servers. You can add the -quiet parameter to get back a True if the string is found and nothing if the string is not found. PowerShell will return each line in the text file that includes the target string. Using the Select-String Cmdlet, you can determine whether or not a specific string value exists in a text file.
