Created
February 23, 2024 07:26
-
-
Save kimboslice99/190f5e5d1e46b52f751eff44dab47648 to your computer and use it in GitHub Desktop.
Update dbip database
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
$download_file = "dbip-country-lite-$((Get-Date).ToString('yyyy'))-$((Get-Date).ToString('MM')).mmdb" | |
$download_url = "https://download.db-ip.com/free/$download_file.gz" | |
# download latest GeoIP database | |
Invoke-WebRequest -Uri $download_url -OutFile "$PSScriptRoot\dbip-country-lite.mmdb.gz" -UseBasicParsing | |
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
$sourceFileStream = [System.IO.File]::OpenRead("$PSScriptRoot\dbip-country-lite.mmdb.gz") | |
$destinationFileStream = [System.IO.File]::Create("$PSScriptRoot\dbip-country-lite.mmdb") | |
$gzipStream = New-Object System.IO.Compression.GzipStream $sourceFileStream, ([System.IO.Compression.CompressionMode]::Decompress) | |
$gzipStream.CopyTo($destinationFileStream) | |
# close streams | |
$gzipStream.Close() | |
$destinationFileStream.Close() | |
$sourceFileStream.Close() | |
Remove-Item "$PSScriptRoot\dbip-country-lite.mmdb.gz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment