How I became a terminal customization junky

In the beginning, there was PS C:\>_ I have been a regular PowerShell users for years. Probably about a decade now and I avoided customizing the shell on my workstation for the vast majority of that time. Despite PSRemoting being a thing for almost the entirety of PowerShell’s existence now. For one reason or another, I would usually end up RDPing into a server just to open PowerShell. I did not want to become dependent on modules like PSReadLine or console emulators like ConEmu for fear I would be handicapped when I had to use PowerShell on another system.

Continuing To Make PowerShell A Bit More Human

Almost two years ago, I learned about a cool project that does some very clever string manipulation. I started messing around with Humanizer and extending existing Types to add some new properties that show off the functionality of Humanizer. Doug Finke started a project at the same time to do the same thing, but using functions. So, we combined our efforts to create one module, PowerShellHumanizer. I, personally, haven’t done much with it since then.

Monitoring With PowerShell and Consul

Getting Started I recently read this article, Consul for Cluster Health Monitoring, and was interested if I could use this to execute PowerShell based health checks. Consul has a Win32 build so it seemed reasonable despite there being no Windows examples in the documentation. Here’s the command I ran to start up a Consul server. Ideally, you’d want a few of these in each physical site and then a Consul agent on each node.

Tools: PowerShell Providers & Website Creation

I found two great tools yesterday. Actually, that’s an grossly inaccurate statement. One of the tools I learned about at the PowerShell Summit earlier this year, but was just finally published to GitHub. The second tool isn’t really a tool, but a site indexing a bunch of tools, or frameworks, for generating static websites.

New Relic is a Bit Sweeter

I’ve been working with New Relic a lot in recent weeks and have deployed their agent several times. Obviously, this required some automation and the best way to automate software installs on Windows is Chocolatey. Unfortunately, New Relic didn’t publish their agents to Chocolatey and the existing packages were out of date.

I brought up the request on the user forum and New Relic expressed interested, but also said, “feel free to give it a try yourself.” So, I did. Here is the .Net agent.

Messing with Photos in PowerShell

In continuing with the habit of building wrappers around .Net libraries mentioned on Scott Hanselman’s blog, I have written a module around James M South’s ImageProcessor.

Here’s an example.

Get-PIPImage -Path C:\Pictures\DSC06199.JPG | 
    Set-PIPImageSize -Width 500 -Height 500 -MaintainAspect | 
    Add-PIPFilter -Filter lomograph | 
    Add-PIPRoundedCorners | 
    Set-PIPImageFormat -Format Png | 
    Save-PIPImage -Path c:\temp\whisky.png

And here is the result.


Humanize follow-up

Humanizer helps you generate some nice output, but it’s kind of a pain to use in PowerShell. You can use Update-TypeData to make the syntax easier to work with. Then, your code starts to look more like the examples on the project’s site.

Here’s a simple example.

Add-Type -Path C:\Humanizer\Humanizer.dll

Update-TypeData -TypeName System.Int32 `
    -MemberType ScriptProperty `
    -MemberName ToWords `
    -value {[Humanizer.NumberToWordsExtension]::ToWords($this)}

PS C:\temp> $int = 1234
PS C:\temp> $int.ToWords
one thousand two hundred and thirty-four

Humanize your scripts

This is a quick example of some of the stuff you can do with Humanizer to make your script’s output a bit more user friendly.

Strings from numbers.

PS C:\temp> [Humanizer.NumberToWordsExtension]::ToWords(2)

PS C:\temp> [Humanizer.NumberToWordsExtension]::ToWords(253)
two hundred and fifty-three

PS C:\temp> [Humanizer.ToQuantityExtensions]::ToQuantity("box", 4)
4 boxes

Test All The Things

This is a follow-up to my last post on using PSate for test automation. I demonstrated running Invoke-WebRequest and validating the StatusCode as a simple test for if a site is available. Now let’s take it to the next level and run an artificial transaction. Again, PSate is a handy test runner to manage this and the open-source project, WatiN (pronounced as What-in) is a great tool for automating a real browser.

Test it with Psate

Recently I have been putting effort into learning the art and science of unit testing using Pester and PSate. I was going to write up something on my experiences, but Jakub JareŇ° beat me to it with this”) good article on PowerShell Magazine. If you are new to the idea of unit testing, go read that article and then come back here.

So, what is the point of this article? I was working on an unusual maintenance recently and it was around 4 in the morning and it occurred to me that it would be nice if I had a big dashboard that showed everything was “green”. It can take 15 minutes or more for monitoring to spool up and do all it’s checks and what happens if you forget to re-enable monitoring after the maintenance. Your mind is completely unreliable after a 20 hour day.

Angular Posh

I just recently found out about a fun project, PoSH Server that has actually been around quite a while. Executing PowerShell from a web page is a powerful idea for a Windows Administrator. Simply access a URL and get back some HTML formatted data—easy to run and consume the results. Just like everything involving PowerShell, there are a number of way to tackle this and I’ve tried quite a few including: PowerShellASP (now PowerShellServer) by /n Software; and Edge for NodeJS. The beauty of PoSH Server is that it’s written entirely in PowerShell which makes it easy to run and tweak. You don’t even need IIS installed. If you have PowerShell installed, install the module and run Start-PoshServer. That is all. Well, that’s enough to get you started. Where you go from there is the challenging and fun part.

Command line tools

The good folks over a Royal Pingdom posted an article today entitled “Powerful command line tools for network administrators.” Of course, by network administrator, they mean Linux admin. Here’s my version for you Windows admins. I guess you could call it “PowerShell command line tools for network administrators.”

Tools: NSSM

Software Deployments with psake on Windows

I’m working on the finishing touches of a Deployment Automation script useing psake (pronounced like sake—the Japanese rice wine) as the framework for creating discreet jobs and enforcing dependencies.

Tools: Pipeworks

PowerShell Pipeworks is a pretty interesting module for PowerShell. Most modules for Posh are focused on doing some discrete task(s). The design principle of Cmdlets is to make single function executables just like Unix shell commands.

I think Pipeworks is the first 3rd party framework I’ve seen developed on Powershell. It’s scripting glue you can use to build automation with Service Oriented Architecture principles. With PowerShell v3 and the whole Windows Management Framework it was packaged in, there is a new Powershell feature called Workflows. Workflows was designed and released also to solve the problem of orchestrating more complex sequences of logic.

Nginx As a Forward Proxy

Everyone wants to do SaaS these days and that includes Infrastructure Monitoring software. That’s a problem when half of your servers do not have internet connectivity and you’d like it to stay that way.