HPE PDU Powershell module

As a follow-up of my exploration of the HPE PDU REST API I wanted to create a Powershell module as a wrapper for the API.

I’ve previously written a post on how to create a Powershell module as a wrapper for an API here. The PDU module will be built in the same way where there will be a private function that handles the actual API requests.

This time I also wanted to go a bit further and split out the functions into individual script files that the module root file will load.
With individual files the maintenance of the functions as well as the split between private and public functions would be easier.

I also wanted to incorporate some Pester tests. At least just for knowing that there’s no syntax errors preventing the files from load.

So instead of one .psm1 module file with all functions and one .psd1 file with the module manifest I create a subfolder with the same name as the module name, and inside that a Private and a Public folder where I put the individual function scriptfiles. We’re also able to split out the test functions from the code.

I won’t go in to great detail on how the structure is built. Please check out this post by Warren, “RamblingCookieMonster”, for a great write up of that.

That post also includes some examples on Pester tests as well as how to publish the code to GitHub and also how to add in continuous integration with AppVeyor.

So, to the actual PDU module and what it does. Currently I’ve included four (public) functions:

  • Get-HPEPdu
  • Get-HPEPduLoadMeasurement
  • Get-HPEPduOutlet
  • Get-HPEPduOutletMeasurement

With these you can retrieve information about the PDU, the segments of it and the specific measurements of all segments and outlets of these segments.

A couple of examples of the usage of the module:

When connecting to a system with the Get-HPEPdu command you get a list of the connected PDUs:

PDU list

If you specify a PDU you will get a lot of details about this specific PDU. Note that the functions support both username/password authentication as well as PS credential objects

PDU details

The module can pull both PDU Load measurements as well as outlet measurements

Outlet measurements

For more information about the usage of the module check out the GitHub repository and the functions have included examples through the normal Powershell help functionality

Note that the webserver serving the API on these PDUs might not be the most powerful you’ve come across so excessive requests can result in the webserver to become temporarily unavailable. This should not affect the normal PDU operations.

I have some thoughts in extending the module and will see if I get around to add more functionality. Please feel free to submit an issue, pull request or fork the repo in GitHub to contribute.

Rudi

Working with Cloud Infrastructure @ Intility, Oslo Norway. VMware vExpert. Mainly focused on automating Datacenter stuff. All posts are personal

Leave a Reply

Your email address will not be published. Required fields are marked *