I'm looking for a PowerShell script that will search all shares on a server for a wildcard of *_HELP_instructions*. An example of a files that it would search for would be 12_HELP_INSTRUCTIONS.txt or 22_HELP_INSTRUCTIONS.html.
So far I have the script below that will search the contents of the C:\, but I need a script that I can setup to search server shares instead.
$FilesToSearch = Get-ChildItem "C:\*" -Recurse -ErrorAction SilentlyContinue |
where {$_.Name -like "*_HELP_instructions*"}
if ($FilesToSearch -ne $null) {
Write-Host "System Infected!"
exit 2015
} else {
Write-Host "System Not Infected!"
exit 0
}
Use
Get-WmiObjectto enumerate the shared folders on the server:The
Where-Objectclause excludes the administrative shares from being scanned (otherwise you could simply scan all local drives).Then call
Get-ChildItemwith the resulting list of paths: