Icon Extraction

Technical Documentation for PowerShell Script
Title/Script Name
Script Name: New-Icon.ps1
Version: 1.0
Author: Preethi B M
Last Updated: 20-April-2025
Purpose: This script is to extract Icons from .exe into 5 different formats.
Overview
This document provides an overview of a script designed to extract icons from .exe files and save them in five different formats: ICO, PNG, JPG, BMP, and GIF. The script offers a straightforward solution for extracting and converting application icons into various image formats, useful for software customization, documentation, or creating app icons.
Prerequisites
List any requirements needed before running the script, such as:
- PowerShell must be installed on Machine.
Parameters
Parameter Name | Type | Description | Default Value |
-FilePath | String | Full Path of the .exe which you want to extract icon | "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe” |
-Format | String | 5 options are provided in dropdown | ico,bmp,PNG,jpg,gif |
Script Description
Provide a detailed explanation of the script’s logic, including:
The script retrieves embedded icons from Windows executable (.exe) files, capturing all five formats.
Extracted icons are automatically converted and saved in any of these five formats which you need to choose — ICO, PNG, JPG, BMP, and GIF.
Ideal for creating app icons, customizing software visuals, or preparing UI mockups, the script offers a quick and flexible solution for handling Windows app icons.
Example Usage
Press the Windows key or click the Start button on the taskbar.
Type PowerShell in the search bar.
From the search results, right-click Windows PowerShell and select Run as Administrator.
If prompted by the User Account Control (UAC), click Yes to grant administrative privileges.
Once PowerShell is running with elevated privileges, you may proceed by pasting the script into the PowerShell window and pressing Enter to execute it.
This script imports a PowerShell module into the console and then execute a specified command from the module.
New-Icon -FilePath "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" -Format PNG
Note - You have drop down to choose -format
This will create a folder named Icons in the script's root directory, where the extracted icon will be stored.
Dependencies
Powershell should exist in the machine
Testing and Validation
This command imports a PowerShell module into the console and then executes a specified command from the module.
Folder Structure:
Conclusion
This PowerShell script automates the extraction of icons from executable (.exe) files.
It streamlines the process, eliminating the need for manual intervention.
Code
<#
.SYNOPSIS
This is a Script which will help us to Create multiple IntuneWinFiles
.DESCRIPTION
Creating bulk intunewin Files
.PARAMETER FileName
No Parameters required
.NOTES
Author: Preethi B M
#>
function New-Icon
{
Param (
[Parameter(Mandatory=$true)][String]$FilePath,
[Parameter(Mandatory)][ValidateSet("ico","bmp","PNG","jpg","gif")]$Format
)
Add-Type -AssemblyName System.Drawing
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($FilePath)
$IconFolder = New-Item -Path $PSScriptRoot -Name "Icons" -ItemType Directory -Force
[System.Drawing.Icon]::ExtractAssociatedIcon($FilePath).tobitmap().Save("$IconFolder\$baseName.$Format")
}
Subscribe to my newsletter
Read articles from Preethi B M directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Preethi B M
Preethi B M
🚀 Automating the future of endpoint management | Microsoft Intune + PowerShell Enthusiast 🛠️ | Simplifying device management one script at a time | Sharing real-world solutions, tips & deep dives 💡