PowerTip: Read .exe Magic Number with PowerShell

Doctor Scripto

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)


Comments are closed. Login to edit/delete your existing comments

Feedback usabilla icon