Extract an App's Icon from an EXE with PowerShell

Use the forgotten Icon.ExtractAssociatedIcon .NET method to rip an executable's icon out to a PNG file.

Windowsiconsystem-drawingpowershellLow risk
Call [System.Drawing.Icon]::ExtractAssociatedIcon on the exe path, convert with ToBitmap(), and save as PNG.

01Command

Command
$ Add-Type -AssemblyName System.Drawing; $ico=[System.Drawing.Icon]::ExtractAssociatedIcon('C:\Windows\System32\notepad.exe'); $ico.ToBitmap().Save('C:\temp\notepad-icon.png',[System.Drawing.Imaging.ImageFormat]::Png)

02What it does

Windows embeds every app's icon inside its executable, and ExtractAssociatedIcon reads it back without any resource editor. The method only returns the 32x32 size — for larger or multi-size icons you would need raw resource extraction — but 32px is enough for docs, READMEs, and shortcuts. ToBitmap converts it into a normal image you can save in any GDI+ format.

03Risk

RiskLow risk
RequirementsWindows PowerShell 5.1 (System.Drawing requires .NET Framework); ExtractAssociatedIcon returns only the 32x32 variant

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-17 · Category: Media

06Related solutions