Skip to content

Instantly share code, notes, and snippets.

@quonic
Last active January 18, 2024 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quonic/ef13ca9f86cf3ab47b2f4810991e7458 to your computer and use it in GitHub Desktop.
Save quonic/ef13ca9f86cf3ab47b2f4810991e7458 to your computer and use it in GitHub Desktop.
Get the bittness of an exe or dll.
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