One of the things I both love and loathe is adding the little icon to an advertised deployment in the Software Center console of SCCM/MEMCM. As many have said it in the past, "Pretty Counts" and I wholeheartedly agree.
The problem I often encounter is that finding (and sometimes, scaling) the right icon can be a huge pain in the ass...especially when deadlines approach (or more often in my case there's an unexpected quick-turnaround need). While SCCM/MEMCM makes the deployment usually quite trivial, I've often spent more time fiddling with the right icon than the deployment script(s) themselves. Recently I was in a situation where I didn't have the luxury of time to try to find a super-specific icon, and when the basic Google image search failed me, I turned to Powershell.
Why Didn't I Do This Before?
Well, to be honest I didn't usually have to use Powershell. But now that I've discovered this functionality I may never look back again!
I knew it was possible to fiddle with the various
.exe parameters to fiddle with the icon, but I hadn't done any of that sort of thing in nearly fifteen years since the days when I wrote commercial software applications. A quick search pointed me at this nugget, with the real source of the Powershell snippet in another post.
In the interest of time, I really just ran the core components of the little cmdlet, most specifically the key bits:
PS C:\path\to\exe\dir> [System.Reflection.Assembly]::LoadWithPartialName('System.Drawing') | Out-Null
PS C:\path\to\exe\dir> $baseName = [System.IO.Path]::GetFileNameWithoutExtension('.\base.exe')
PS C:\path\to\exe\dir> [System.Drawing.Icon]::ExtractAssociatedIcon('.\base.exe').ToBitmap().Save("$baseName.png")
This was more or less my moment-in-time hack to get the icon (saved as a PNG), and definitely not something you'd do at scale (or maybe more than once or twice).
I very much intend to take the original example given and massage this into my regular snippet library, because it was definitely a lifesaver. Super easy to use, and no fiddling around to search, scale, and save the silly (but important) little icon file.