GUI no more... #PowerShell modules for several CI/CD tools

I am a console guy, you know. Although a graphical user interface (GUI) is a great way to visualize data, it often falls short of its potential when it does not correlate data. That’s when a command line tool comes into play. It enables you to retrieve different kinds of data and process them yourself. And since, I love PowerShell, what better way than replacing GUIs using cmdlets?!

I have recently started to use my evenings to write cmdlets to query all systems that I usually work with and created PowerShell modules for them:

Considering those modules work very similar under the hood, I have factored out some functionality. This is provided by dependent modules called WebRequest and Helpers. Unfortunately, they are not installed automatically - therefore, you need to install them as well:

The following commands can be used to install all modules including the dependencies:

Install-Module -Name Helpers, WebRequest -Scope LocalUser -AllowClobber
Install-Module -Name Artifactory, BitBucket Cloud, BitBucket Server, GoCD, InfluxDB, Rancher -Scope LocalUser

Please note that WebRequest overwrites Invoke-WebRequest and Invoke-RestMethod to provide authentication and other features missing from those cmdlets. If you want to use the functionality of the original cmdlets, please unload the module (Remove-Module -Name WebRequest) or call the original cmdlet explicitly (Microsoft.PowerShell.Utility\Invoke-WebRequest and Microsoft.PowerShell.Utility\Invoke-RestMethod).

All of those modules are still in an early phase of development. They focus on retrieving data for analysis in PowerShell but some already provide cmdlets for modifying the product. They are dearly missing documentation as well as unit tests. But as I am using them almost daily, those will be added over time.

I will introduce the modules separately to demonstrate the advantages of those modules. But there is a common design aspect I’d like you to take note of. After importing the dependencies and the required module…

Import-Module -Name Helpers,WebRequest,InfluxDb

…you need to set credentials for the service…

Set-InfluxDbServer -Server influxdb.mydomain.com -User myuser -Token mytoken

Also note that WebRequests has proxy support built in. In case you are using these modules behind a proxy server, execute the following commands:

$ProxyPreference = 'Proxy'
$ProxyServer = 'http://1.2.3.4:3128'

Introductory posts

Using PowerShell to talk to InfluxDB

Feedback is always welcome! If you'd like to get in touch with me concerning the contents of this article, please use Twitter.