-
Notifications
You must be signed in to change notification settings - Fork 3
/
check-log4j_offline.ps1
35 lines (26 loc) · 1.19 KB
/
check-log4j_offline.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$pcname = Read-host "Enter PC name (for logfile naming)"
$ignoreDrives = ()
#$ignoreDrives = @("A", "B" , "K" , "L" ) # A and B are USUALLY not relevant, D is the Azure temp disk; add any nessecary drives here.
$keyword = "*log4j-core*.jar"
$logpath = ".\Logs\scan" # If you need Logs to go on a network share, edit this parameter!
$logfile = "$path\log4j-servercheck-werkplek-$pcname.log"
If(!(test-path $logpath))
{
New-Item -ItemType Directory -Force -Path $logpath
}
Start-Transcript -Path $logfile
$drives = Get-PSDrive -PSProvider FileSystem
foreach ($drive in $drives) {
if ($drive.Name -notin $ignoreDrives) {
$items = Get-ChildItem -Path $drive.Root -Filter $keyword -ErrorAction SilentlyContinue -File -Recurse
foreach ($item in $items) {
$item.FullName # Show all files found with full drive and path
}
}
}
Stop-Transcript
<#
This is a quick script, don't expect it to be too neat.
It should work for it's intended purpose, readability may be a bit harsh.
15-12-2021: Edited for offline use -> by Jan W
#>