Last active
January 18, 2024 22:27
-
-
Save quonic/ef13ca9f86cf3ab47b2f4810991e7458 to your computer and use it in GitHub Desktop.
Get the bittness of an exe or dll.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ProgramBit { | |
[CmdletBinding()] | |
param ([string]$Path) | |
process { | |
if (-not $(Test-Path -Path $Path -ErrorAction SilentlyContinue)) { | |
Write-Error "Invalid Path" | |
return | |
} | |
$re32 = [regex]::new('PE\W\WL') | |
Get-Content -Path $Path -ReadCount 1 | ForEach-Object { | |
if ($re32.Match($_).Success) { | |
return 32 | |
} | |
} | |
return 64 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment