Skip to content

Commit

Permalink
Merge pull request #1 from thedxt/URL-tweak
Browse files Browse the repository at this point in the history
adding DLURI to allow getting the MS JSON URI from a txt file rather than changing the script each time
  • Loading branch information
thedxt authored Jan 11, 2021
2 parents 5d14610 + ee357f9 commit 556e775
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 5 additions & 6 deletions Azure-IP-Downloader.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Azure IP filter and downloader script v1.0
# Azure IP filter and downloader script v1.1.0
# Author: Daniel Keer
# Author URI: https://thedxt.ca
# Script URI: https://github.com/thedxt/IP-Downloader
Expand All @@ -11,19 +11,19 @@
# the uri from MS will need to be replaced as that may change
# the uri is here https://www.microsoft.com/en-us/download/details.aspx?id=56519
#
#
# change the variables as needed


#save location
$exportlocation = "C:\temp\"

#region filter
$regionFilter = "canada"

#download the JSON file from MS
$MSjsonDL = Invoke-WebRequest -Uri "https://download.microsoft.com/download/7/1/D/71D86715-5596-4529-9B13-DA13A5DE5B63/ServiceTags_Public_20210104.json"
#grab URI from txt file
$DLURI = Invoke-WebRequest -uri "https://raw.githubusercontent.com/thedxt/IP-Downloader/main/URIs/Azure-JSON-URI.txt"

#download the JSON file from MS
$MSjsonDL = Invoke-WebRequest -Uri $DLURI.Content

#getting date
$time = get-date -f yyyy_MMM_dd_hhmm_tt
Expand All @@ -34,7 +34,6 @@ $MSjsonOBJ = ConvertFrom-Json $MSjsonDL
#select the values
$properties = $MSjsonOBJ.values.properties


#filter to pick only specific regions and null for ones that dont have regions
$regions = $properties | where-object { $_.region -match $regionFilter -OR $_.region -eq ""}

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Azure IP filter and downloader script v1.0
# Azure IP filter and downloader script v1.1.0
Grabs the JSON file for the Azure IP Ranges and Service Tags – Public Cloud.

Script allows for flitering and downloads the ips into one big file it also makes a file just for IPv4 and IPv6
Expand All @@ -10,6 +10,7 @@ The uri from microsoft will need to be replaced as that may change (they update
* change your region filter as needed to suit your needs
* in download the JSON file from MS replace the uri in from MS when they update the file to keep it as updated as possible
* the filter includes null regions as some of the data doesn't have a region
* DLURI will grab the most recent MS URI that I've saved in URIs/Azure-JSON-URI.txt. You can change this to something you control. All that you have to do after that is just update the URI in that file and the reset of the script doesnt need to change.

## known issues
* C:\temp needs to exist
1 change: 1 addition & 0 deletions URIs/Azure-JSON-URI.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://download.microsoft.com/download/7/1/D/71D86715-5596-4529-9B13-DA13A5DE5B63/ServiceTags_Public_20210104.json

0 comments on commit 556e775

Please sign in to comment.