This script will search folders listed in the path variable.
$Search4 = "Microsoft.Windows.WinSqm" # Look for this character string
$PathFolders = $env:path.split(";")
foreach ($Folder in $PathFolders) {
"Analyzing folder $Folder"
if (Test-Path $Folder) {
$Files = Get-ChildItem -Path $Folder -File
foreach ($F in $Files) {
$Data = Select-String -Path $F.FullName -Pattern $Search4 -Encoding unicode -ErrorAction SilentlyContinue
if ($Data) {
"Unicode found in {0}" -f $f.FullName
} else {
$Data = Select-String -Path $F.FullName -Pattern $Search4 -Encoding ascii -ErrorAction SilentlyContinue
if ($Data) {
"ASCII found in {0}" -f $f.FullName
}
}
}
} else {
"Folder does not exist."
}
}