Skip to main content

3 posts tagged with "api"

View All Tags

· 2 min read
Hannes Palmquist

Recently i published a new module PSDev with the purpose to group together a set of utility functions. Most of the functions are stand-alone and can be used independently of the module. The module is published to PSGallery for ease of access.

Install-Module PSDev -Scope CurrentUser

PSDev Module Docs

Function: Get-Office365IPURL

The first addition to the module is the Get-Office365IPURL and Test-Office365IPURL functions. These functions simplify the process of getting a list of firewall rules for a given set of services and troubleshoot communication issues.

Get-Office365IPURL is used to get a detailed list of the rules. The Office 365 website combines, protocol, port and type of openings. This function will expand these rules based on these attributes. See the example below.

Get-Office365IPURL -Services Exchange -Types IP4,URL | Where-Object {$_.Required -eq $true}

Group Service Type Protocol Port Endpoint Required
----- ------- ---- -------- ---- -------- --------
Exchange_TCP_25_IP Exchange IP4 TCP 25 52.100.0.0/14 True
Exchange_TCP_25_IP Exchange IP4 TCP 25 104.47.0.0/17 True
Exchange_TCP_25_IP Exchange IP4 TCP 25 40.107.0.0/16 True
Exchange_TCP_25_IP Exchange IP4 TCP 25 40.92.0.0/15 True
Exchange_TCP_443_IP Exchange IP4 TCP 443 40.96.0.0/13 True
Exchange_TCP_443_IP Exchange IP4 TCP 443 204.79.197.215/32 True
Exchange_TCP_25_URL Exchange URL TCP 25 *.mail.protection.outlook.com True
...

Get-Office365IPURL Docs

Function: Test-Office365IPURL

Test-Office365IPURL is used to test weather a IP address is included within the ipranges provided by Microsoft. This could be useful of the firewall logs shows that a connection to an IP adress is blocked and there is a need to verify if that IP belongs to the ranges provided by Microsoft. See the example below.


Test-Office365IPURL -IP 52.109.76.22 | Where-Object {$_.ismember -eq $true} | Format-Table

RuleID ServiceArea TCPPort UDPPort Required Range Subject IsMember
------ ----------- ------- ------- -------- ----- ------- --------
46 Common 80,443 True 52.108.0.0/14 52.109.76.22 True
64 Common 443 True 52.108.0.0/14 52.109.76.22 True
65 Common 80,443 True 52.108.0.0/14 52.109.76.22 True

Test-Office365IPURL Docs

· 2 min read
Hannes Palmquist
info

This script has been integrated in the module PSDev and is no longer provided as a stand-alone script.

At the time of writing this post there is no native automated way to cleanup/remove github artifacts produced within GitHub Action Workflows. If you for instance have an automated build process you will quite fast hit the free storage quota in GitHub and you'll have to start paying for additional storage. There are a few available options to manage this. You could manuallly remove each workflow run that could contain artifacts. This could be timeconsuming work. You could also configure the retension time of workflows in each repo. However both of these will remove the logs of each workflow run as well. A better way if you don't need the artifacts after the workflow run is to add a cleanup job to the workflow. I've been using geekyeggo/delete-artifact@v2. This action till remove the artifacts that i specify in the workflow file automatically within a cleanup job at the end of the workflow. This works great for future workflow runs once you configure the cleanup job. But what about if you have hit the storage quota and need to cleanup all existing artifacts? Then you would have to do it manually or call the GitHub Rest API and remove all artifacts. This is what the below script does, it will enumerate all artifacts for a specific repo or all repos for a user account and remove all artifacts.

Remove-GitHubArtifact -GitHubSecret "ABC" -GitHubOrg "user"

Repo Artifacts_Found Artifacts_Removed Artifacts_SizeMB
---- --------------- ----------------- ----------------
PSDaikin 5 5 43
PSDataSet 2 2 2
PSMaintenanceManager 2 2 21
PSPortainer 34 34 321
PSQueue 0 0 0
PSScriptInfo 0 0 0
PSSort 0 0 0

Or for a specific repo:

Remove-GitHubArtifact -GitHubSecret "ABC" -GitHubOrg "user" -Repo "PSMaintenanceManager"

Repo Artifacts_Found Artifacts_Removed Artifacts_SizeMB
---- --------------- ----------------- ----------------
PSMaintenanceManager 2 2 21
danger

The script will remove all artifacts for the specified repo or all repos on the account. This is destructive and can not be reversed.

· One min read
Hannes Palmquist

Some time ago I wanted to automate a process where I needed check status of a few docker containers managed with Portainer and noticed that there was no powershell module available on the gallery for portainer. A couple of minutes later I had discovered the Portainer Rest API and though that it could be a fun project to provide powershell users with the ability to manage their Portainer and Docker instances with powershell.

So here it is, an early pre-release/work in progress powershell module for Portainer, PSPortainer

If you want to contribute to the project it is publically available on GitHub here

To get started, visit the docs for the module at getps.dev or start exploring directly by installing the module from PSGallery

Install-Module PSPortainer -Scope CurrentUser