Skip to content

Instantly share code, notes, and snippets.

@pronichkin
Last active June 15, 2021 19:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pronichkin/b1fcd7b797ed7194dce0a96d98765aa7 to your computer and use it in GitHub Desktop.
Save pronichkin/b1fcd7b797ed7194dce0a96d98765aa7 to your computer and use it in GitHub Desktop.
Get-Process | Sort-Object -Unique -Property 'Name' | Select-Object -Property @(
@{
'Label' = 'Name'
'Expression' = {
$psItem.Name
}
}
@{
'Label' = 'Hash'
'Expression' = {
$MemoryStream = [System.IO.MemoryStream]::new()
$StreamWriter = [System.IO.StreamWriter]::new( $MemoryStream )
$StreamWriter.write( $psItem.MainModule.ModuleName )
$StreamWriter.Flush()
$MemoryStream.Position = 0
$Hash = Get-FileHash -InputStream $MemoryStream -Algorithm 'SHA1'
$HexString = '0x' +
$Hash.Hash.Substring( 6, 2 ) +
$Hash.Hash.Substring( 4, 2 ) +
$Hash.Hash.Substring( 2, 2 ) +
$Hash.Hash.Substring( 0, 2 )
[System.uInt32]$HexString
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment