mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-05 18:11:19 +01:00
Updated scan-folder.ps1
This commit is contained in:
parent
54844ed993
commit
63ffa48dc4
@ -469,6 +469,7 @@ CDR,call detail record
|
|||||||
CDR,Computed Dental Radiography
|
CDR,Computed Dental Radiography
|
||||||
CDSL,Consumer Digital Subscriber Line
|
CDSL,Consumer Digital Subscriber Line
|
||||||
CDSS,clinical decision support system
|
CDSS,clinical decision support system
|
||||||
|
CDU,Coolant Distribution Unit
|
||||||
CdTe,cadmium telluride
|
CdTe,cadmium telluride
|
||||||
CEBP,communications-enabled business processes
|
CEBP,communications-enabled business processes
|
||||||
CELL,Cell processor
|
CELL,Cell processor
|
||||||
|
|
@ -1,13 +1,13 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Scans a directory tree for malware
|
Scans a folder for malware
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script scans a directory tree for malware. Requires the installation of ESET or Windows Defender.
|
This PowerShell script scans a folder for malware (including subfolders). Requires ESET Endpoint Security or Windows Defender.
|
||||||
.PARAMETER path
|
.PARAMETER path
|
||||||
Specifies the file path to the folder (default is working directory).
|
Specifies the file path to the folder (default is working directory).
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./scan-folder.ps1 C:\Windows
|
PS> ./scan-folder.ps1 C:\Windows
|
||||||
⏳ Scanning 📂C:\Windows with ESET Antivirus...
|
⏳ Scanning C:\Windows with ESET Endpoint Security...
|
||||||
...
|
...
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -24,22 +24,20 @@ try {
|
|||||||
$path = Resolve-Path $path
|
$path = Resolve-Path $path
|
||||||
|
|
||||||
if (Test-Path "C:\Program Files\ESET\ESET Security\ecls.exe" -pathType leaf) {
|
if (Test-Path "C:\Program Files\ESET\ESET Security\ecls.exe" -pathType leaf) {
|
||||||
|
Write-Host "⏳ Scanning $path with ESET Endpoint Security..."
|
||||||
"⏳ Scanning 📂$path with ESET Antivirus..."
|
|
||||||
& "C:\Program Files\ESET\ESET Security\ecls.exe" $path
|
& "C:\Program Files\ESET\ESET Security\ecls.exe" $path
|
||||||
if ($lastExitCode -ne 0) { throw "ESET Antivirus failed with exit code $lastExitCode - POTENTIAL DANGER!!!" }
|
if ($lastExitCode -ne 0) { throw "ESET Endpoibnt Security exited with code $lastExitCode - POTENTIAL THREAT !!!" }
|
||||||
|
|
||||||
} elseif (Test-Path "C:\Program Files\Windows Defender\MpCmdRun.exe" -pathType leaf) {
|
} elseif (Test-Path "C:\Program Files\Windows Defender\MpCmdRun.exe" -pathType leaf) {
|
||||||
|
Write-Host "⏳ Scanning $path with Windows Defender..."
|
||||||
"⏳ Scanning 📂$path with Windows Defender..."
|
|
||||||
& "C:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -ScanType 2 -File $path
|
& "C:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -ScanType 2 -File $path
|
||||||
if ($lastExitCode -ne 0) { throw "Windows Defender failed with exit code $lastExitCode - POTENTIAL DANGER !!!" }
|
if ($lastExitCode -ne 0) { throw "Windows Defender exited with code $lastExitCode - POTENTIAL THREAT !!!" }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw "Found no ESET or Windows Defender - please install one."
|
throw "No ESET Endpoint Security or Windows Defender available - please install one."
|
||||||
}
|
}
|
||||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
"✅ Scanned 📂$path in $($elapsed)s: No malware found."
|
Write-Host "✅ Scanned $path in $($elapsed)s: No malware found."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error: $($Error[0])"
|
"⚠️ Error: $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user