Created
June 28, 2021 23:25
-
-
Save kbni/d5986f5ff046aa3783e8a9465dd15eaa to your computer and use it in GitHub Desktop.
Download some cute icons I found on the interwebs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent) | |
$IconDownloadTemplate = 'https://img.icons8.com/windows/2x/{colour}/{thing}.png' | |
$IconSaveTemplate = 'icons/{thing}.{colour-name}.png' | |
$WantedIcons = @' | |
https://img.icons8.com/windows/2x/{colour}/server | |
https://img.icons8.com/windows/2x/{colour}/windows-client | |
https://img.icons8.com/windows/2x/{colour}/linux-client | |
https://img.icons8.com/windows/2x/{colour}/mac-client | |
https://img.icons8.com/windows/2x/{colour}/thin-client | |
https://img.icons8.com/windows/2x/{colour}/router | |
https://img.icons8.com/windows/2x/{colour}/wifi-router | |
https://img.icons8.com/windows/2x/{colour}/server | |
https://img.icons8.com/windows/2x/{colour}/switch | |
https://img.icons8.com/windows/2x/{colour}/voip-gateway | |
https://img.icons8.com/windows/2x/{colour}/nas | |
https://img.icons8.com/windows/2x/{colour}/high-connection | |
https://img.icons8.com/windows/2x/{colour}/phone | |
https://img.icons8.com/windows/2x/{colour}/firewall | |
https://img.icons8.com/windows/2x/{colour}/workstation | |
https://img.icons8.com/ios/2x/{colour}/multifunction-printer | |
'@ -split '\s+' | Where-Object { $_ } | |
$WantedColours = @{ | |
green = '006600' | |
grey = '888888' | |
} | |
$WebClient = New-Object System.Net.WebClient | |
Function SubTpl { | |
Param($str, $subs) | |
$subs.GetEnumerator() | ForEach-Object { | |
$str = $str.Replace('{{{0}}}' -f $_.Name, $_.Value) | |
} | |
$str | |
} | |
Foreach($colour in $WantedColours.GetEnumerator()) { | |
Foreach($url_tpl in $WantedIcons) { | |
$ctx = @{ | |
'thing' = (Split-Path -Leaf $url_tpl) | |
'colour-name' = $colour.Name | |
'colour' = $colour.Value | |
} | |
$url = SubTpl $IconDownloadTemplate $ctx | |
$dest = SubTpl "icons/{thing}.{colour-name}.png" $ctx | |
If(-Not (Test-Path $dest)) { | |
New-Item -ItemType Directory -Name $(Split-Path -Parent $dest) -Force | Out-Null | |
Write-Verbose -Verbose "Downloading $url" | |
Get-Item $dest -ErrorAction SilentlyContinue | Remove-Item | |
Invoke-WebRequest -Verbose -Uri $url -OutFile $dest | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment