PowerShell to download O365 IP ranges

 
$ipv4CsvFile = "${env:USERPROFILE}\Documents\O365_IPv4_Addresses.csv"
$ipv6CsvFile = "${env:USERPROFILE}\Documents\O365_IPv6_Addresses.csv"
 
[xml]$xml = ( New-Object System.Net.WebClient ).DownloadString( "https://support.content.office.net/en-us/static/O365IPAddresses.xml" )
 
$products = $xml.products.product
 
$ipList = $products.addresslist.Where( { ( $_.type -in ("IPv4","IPv6") ) -and ( $_.address -ne $null ) } )
 
$ipv4 = ($ipList.Where({ $_.Type -eq 'IPv4'})).address
$ipv6 = ($ipList.Where({ $_.Type -eq 'IPv6'})).address
 
$ipv4 | Out-File -Filepath $IPv4CSVFile
$ipv6 | Out-File -Filepath $IPv6CSVFile

megaport-pstools Released

https://bitbucket.org/cbrochere/megaport-pstools/src

megaport-pstools

PowerShell Tools for automation and scripting of Megaport services.

This started life with the purpose of figuring out how one might schedule a bandwidth change on a VXC, but then blew-up into various other tools to simplify other tasks and requests from user, such as exporting and graphing the bandwidth usage, or detecting interface/connection issues.

While the Megaport web UX at https://megaport.al is really great, simple and intuitive, it’s a pain having to click buttons over-and-over – and besides, It ain’t “DevOps-y” cool. There’s always a need for scripted automation with integration with other powershell suites such as the Azure PowerShell Tools.

Why PowerShell? -meh! why not? -Actually, I’ve just been spending a lot of time on Windows lately, running/writing Azure automation scripts, so it was pretty easy to write up a few test scenarios using the API and Invoke-RestMethod. By the time I completed testing 4-5 API endpoints, I was already reusing the majority of the same code, so it pretty much escalated/optimized from there.

Btw – PowerShell works on both Windows, Mac (untested) and Linux, VS Code is pretty and cool too 🙂