Extract an EXE Icon to PNG Using PowerShell

Use PowerShell native .NET capabilities to extract application icons from executables without third-party tools.

Published 2025-10-08 by Josue Valentin

Need to grab an icon from a Windows application for documentation, shortcuts, or deployment visuals? Here's how to extract it using PowerShell's native .NET capabilities-no third-party software required.

The Script

Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName System.Windows.Forms

# Open file dialog to select EXE
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$openFileDialog.Filter = "Executable files (*.exe)|*.exe"
$openFileDialog.Title = "Select an EXE file"

if ($openFileDialog.ShowDialog() -eq 'OK') {
    $exePath = $openFileDialog.FileName
    $icon = [System.Drawing.Icon]::ExtractAssociatedIcon($exePath)

    # Convert to bitmap and save as PNG
    $bitmap = $icon.ToBitmap()
    $outputPath = [System.IO.Path]::ChangeExtension($exePath, "png")
    $bitmap.Save($outputPath, [System.Drawing.Imaging.ImageFormat]::Png)

    Write-Host "Icon saved to: $outputPath"

    # Clean up
    $bitmap.Dispose()
    $icon.Dispose()
}

How It Works

The script:

Use Cases