March 19th, 2015

PowerTip: Read .exe Magic Number with PowerShell

Doctor Scripto
Scripter

Summary: Learn how to use Windows PowerShell to see an .exe magic number.

Hey, Scripting Guy! Question How can I use Windows PowerShell to see the "magic number" associated with an executable file in Windows?

Hey, Scripting Guy! Answer The term magic number refers to the bytes that occur at the beginning of every file and identify the format of file.
           Use this command to read a Windows executable file header with Windows PowerShell:

 [char[]](gc $env:windir\notepad.exe -Encoding Byte -ReadCount 1 -TotalCount 2)

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.