Uses ExtractIconExW function to extract icons from libraries. This function should be compatible with both, Windows PowerShell 5.1 and PowerShell 7+. It will extract both icons, large and small, from a given index (-InconIndex). The function outputs 2 FileInfo instances pointing to the created icons given in -DestinationFolder. If no destination folder is provided, the icons will be extracted to the PowerShell current directory ($pwd).
# Extracts `shell32.dll` icon index 0 to PWD
Invoke-ExtractIconEx shell32.dll -Index 0
# Extracts `user32.dll` icon index 1 and 2 to a specified path
Invoke-ExtractIconEx user32.dll .\pathto\destinationFolder -Index 1, 2
# Extracts ALL icons from `shell32.dll` to PWD
Invoke-ExtractIconEx shell32.dll