Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2021 21:14
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
PowerShell script to find log4j-core.jar files
Function Get-log4files(){
$Drives = Get-PSDrive | Select-Object -ExpandProperty 'Name' | Select-String -Pattern '^[a-e]$'
$FileInfo = [System.Collections.ArrayList]::new()
$Filetypes = @("*.jar")
ForEach($DriveLetter in $Drives)
$Drive = "$DriveLetter" + ":\"
$Log4Files = Get-ChildItem -Path $Drive -Filter "*log4j-core*" -Include $Filetypes -Recurse -File -ErrorAction SilentlyContinue | Select-Object FullName
Foreach($file in $Log4Files)
if(-not [string]::IsNullOrEmpty($file.FullName))
$Result = [PSCustomObject]@{
D = $env:ComputerName
FH = (Get-FileHash -Path $file.FullName -Algorithm SHA256).Hash
F = $file.FullName
Copy link

g0nz01 commented Dec 16, 2021

Is this script built to output results regardless if files are found or NOT? I can't tell when I look at each of your lines. And I've ran the script on a test machine with no output/results file to be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment