I'm in the process of writing a Powershell script
that will create my ConfigMgr 2012 applications for me. One part of this process is associating an icon with the application.
The method I'm doing this does, in fact, attach the .ICO
file that I'm telling it but the quality is horrible. I attach this same .ICO
file to an existing application in the GUI and it looks great. I've tried all kinds of tricks using System.Drawing.Bitmap, System.Drawing.Image
, etc but it either throws an exception because it can't convert it to a Byte type or when it doesn't do that, the application crashes my ConfigMgr console when I try to view it.
Here's my current code:
$icon = New-Object Microsoft.ConfigurationManagement.ApplicationManagement.Icon
$x = [System.Drawing.Icon]::ExtractAssociatedIcon($FilePathToIcon)
$icon.Data = $x
return $icon
I then go onto add the $Icon object to my Application object. I already have the .ICO file. My thinking at this point is that I shouldn't have to extract an icon if I already have an ICO file but I can't, for the life of me, figure out how to get this thing in a decent quality.