AWS PowerShell - Intro to PowerShell Lambdas, Creating An Automatic Shutdown Policy for EC2 Instances

AWS has finally released support for PowerShell lambdas! Lambdas are pieces of code that can be called from just about anywhere in AWS (or outside for that matter). Even better lambdas don’t require a server to run, this means that you only pay for the compute that you actually use. Don’t worry the first 1M hits per month are free. Let’s dive in and see how we can start using our existing PowerShell skills to start building lambdas.

The Good Stuff: Start writing AWS Lambdas in PowerShell.

Read More

AWS PowerShell - EC2 Tags and Filtering

One of the biggest shifts in moving to the cloud is getting used to the fact that servers don’t matter. You have a workload, you build a couple of instances and it runs. If there’s an issue you’re not going to troubleshoot a server. Tear it down and spin up a new one. With all these servers coming and going, it’s important to be able to keep everything organized. One way AWS solves this is through the use of instance tags. Let’s dive in and learn to work with them in PowerShell.

The Good Stuff: Start leveraging tags to organize your AWS instances!

Read More

AWS PowerShell - EC2 Key Pairs, Credentials and Connecting

Now that we know how to provision machines, I want to dive deeper into KeyPairs and how we can connect. When working with on perm machines, credentials are easy. Traditionally all you have to pass is your domain credentials and go. While you can extend active directory to the cloud (or use a hosted version), this is becoming less and less common. Let’s dig in and see how we can use key pairs to create credentials and connect.

The Good Stuff: Helper functions that speed up PsSession and RDP Creation for Windows EC2 Instances.

Read More

AWS PowerShell - Creating Ec2 Instances and Basic Machine Management

The AWS Tools for PowerShell let you manage all your EC2 instances with cmdlets. With full coverage for machine creation, deletion and updating, virtually all settings are configurable from the PowerShell console. Let’s dive in and learn to create and manage EC2 Instances from PowerShell!

The Good Stuff: Check out the AWS Tools for Powershell and start managing EC2 from your shell today

Read More

AWS PowerShell - Finding the Right EC2 Image

Now that we have the AWS Tools installed and our shell setup, it’s time to start creating machines. The most basic and probably most used feature of AWS is EC2. There are literally thousands of different images to choose from. With so many options and settings to tweak, finding the right image and starting a machine can sometimes feel overwhelming. Luckily with the AWS tools for PowerShell, we’ll have everything we need to find the right image.

The Good Stuff: Learn how to find and start an EC2 Image with PowerShell.

Read More

AWS PowerShell - Setting up AWS Tools on PowerShell Core

It’s almost impossible to talk about DevOps these days without mentioning the cloud. People are incredibly passionate about which service is the best and why. Whatever your opinion, it’s undeniable that Amazon Web Services (AWS) is one of the most mature and feature-rich providers in this space. They treat PowerShell like a first-class citizen and best of all, you can run AWS tools for Powershell in PowerShell core!

The Good Stuff: Check out AWS Tools for Windows PowerShell

Read More

Exploring PowerShell 6 - A Better Split-Path

PowerShell Core 6.0 is out! There’s a ton of new features and even some old commands are getting some love. Today we’re gonna talk about some of the improvements that made it into Split-Path. Let’s dive in and see what the team brought us.

The Good Stuff: There’s a new improved Split-Path with a couple quality of life changes, check it out!

Read More

Exploring PowerShell 6 - SpeedFreaks

PowerShell Core 6.0 is out! Along with all the new features, there has been a ton of performance improvements. But just really how much faster is it? Today I’m going to revisit an old article by Dave Wyatt and see if version 6 has the numbers to back up all the claims. So with that, let’s dive into the filtering performance improvements in the latest version.

The Good Stuff: PowerShell version 6, now with faster filters!

Read More

Exploring PowerShell 6 - Character Ranges

PowerShell Core 6.0 is now out and available for download. Today I want to talk about a feature that may have taken PowerShell golf to a new level. New with this release we can now enumerate character ranges, and skip the whole cast to char step! Let’s dive in and take a look.

The Good Stuff: Take a look at "a".."z" and enumerate characters the easy way.

Read More

Exploring PowerShell 6 - Service Cmdlets Easy Mode

I’m not sure if you guys have heard, but PowerShell Core 6.0 is out. Today I want to talk about some of my favorite quality of life improvements. There have been some changes to the *-Service cmdlets. Let’s dive in and take a look.

The Good Stuff: Start playing with the new features on the Service cmdlets in PowerShell 6.

Read More

Exploring PowerShell 6 - ValidateRange Enhancements

PowerShell Core 6.0 is here! One of the new features is some enhancements to the ValidateRange attribute. As part of the update, you can now pass predefined ranges making common scenarios a little easier. Let’s dive in and take a look.

The Good Stuff: ValidateRange now has predefined shortcuts that you can leverage in PowerShell 6.

Read More

Exploring PowerShell 6 - Backgrounding Pipelines

PowerShell Core 6.0 is here and with it are a ton of new features. I’ve been going through some of the release notes and Github pages trying to find cool stuff to play with. On the docket for today is backgrounding the pipeline.

The Good Stuff: Check out background pipes using & in PowerShell 6.0.

Read More

Finding An Available File Name

The last couple of weeks I’ve been doing a lot of reorganizing of some of my media files. Part of this reorg has been shifting files around and consolidating folders. One challenge I ran into was having files with conflicting names. Since I don’t want to accidentally override any files, I created this helper function to test if a file name already exists. If it does detect a conflict, it will keep appending a number until it finds an available name.

The Good Stuff: Use Get-AvailableFileName to help find a name that’s not already in use.

Read More

Module Tools - Adding Cmdlet Help With PlatyPS

So the bad news is we have to write help for our modules. The good news is PlatyPS streamlines the process and makes it a lot more bearable. Plus all of the help can be written in Markdown and packaged up for easy distribution. I promise, even though we’re writing help, it won’t be too bad.

The Good Stuff: Start using PlatyPS to build your help files.

Read More

Module Tools - Folder layout

Next up in our series of working with Module Tools is folder layout. In our first post, we used Plaster to scaffold our new module. Now let’s dive into the folder structure and how this layout can simplify our development.

The Good Stuff: Make your module development easier by writing small functions and keeping them in own PS1 files.

Read More

Module Tools - Starting Off

This is going to be the first in a series of posts related to working with module tools. In my previous article, I talked about what tools module authors should leverage. Now I want to walk through using these tools and demonstrate how they all come together. To do this, we will be creating a new module called HideWindowsExplorerDrives. The purpose of this module is to make hiding and showing explorer drives easier. The code is beside the point. I want to focus more on how we can use some of these community projects to take our module to the next level.

The Good Stuff: Setting up a new module project using my Plaster Template.

Read More

Tools Module Authors Should Leverage

Writing a PowerShell module is hard. A lot harder than it used to be. Honestly it’s your fault. Not just you, but the whole PowerShell community. Apparently we’re a mature language now and everybody is demanding more. I mean I was just starting to accept that fact that I have to include Pester tests, but now I need documentation too? What else does it take to write a professional quality module these days?

The Good Stuff: The skills you should be investing in to take your modules to the next level.

Read More

SysAdmin Basics - Working With IP Addresses

Whether you like it or not, at some point in your career you will be working with IPs. I recently ran into a challenge at work with variable length subnet masks that inspired this post. I needed to brush off some old networking skills and got to play with a little PowerShell along the way. With that in mind, let’s get into it.

The Good Stuff: A couple of tricks to make working with IPs a little less painful.

Read More

SysAdmin Basics - Finding A Specific Date

Dates are hard, that makes scheduling hard. Ever had someone tell you to be ready on the first Monday of the month? Don’t forget patches come out on the second Tuesday. My personal favorite is the fourth Thursday in November (Thanksgiving here in the states). While these types of dates are easy to remember, they can be hard to build automation around. Don’t worry with a couple of tricks and my helper function, I’ll make sure you never miss Mother’s Day again (second Sunday in May).

The Good Stuff: Get-SpecificDate, a function to find day of week occurrences in a given month.

Read More

Using Inheritance To Build DSC Resources

Today we are going to use inheritance to create multiple DSC resource from a base class. I’m the first to admit I’m lazy and always trying to get the most bang for my lines of code. Inheritance is a great way to reduce code duplication and pretty easy once you wrap your head around it.

The Good Stuff: My DSC FileWatcher module and an example of building resources with inheritance.

Read More

Non-Interactive Plaster

I have a talk coming up on Plaster. It’s been almost 2 months since my post on it and I’ve been playing around the last couple of days to get comfortable. One thing that hit me was that Plaster will turn the parameters in your manifest into dynamic parameters of the Invoke-Plaster cmdlet. What this means is you could pull a list from anywhere and run that through a Plaster manifest, all without stepping through the wizard!

The Good Stuff: Make sure you’re using Plaster’s dynamic parameters.

Read More

Troubleshooting DSC

While I know everyone out there writes perfect code first try, I am not so lucky. I’m a little superstitious but I think if your code works first try, it’s bad luck. We’ve all been there, you’ve been chugging away at a new project, go to run it and it blows up. Even worse, sometimes you have a resource that’s been working great, but chokes on a particular server. No way around it, debugging and troubleshooting are part of the game. This article will take your existing debugging knowledge and help you apply it to DSC.

The Good Stuff: How to Debug a DSC Resource.

Read More

DSC Classes - Using Helper Methods

This is going to be part two on DSC Classes. Today we are going to cover a resource with more than the standard Get,Set and Test methods. Helper methods are a great way to organize your resource. By making use of class properties and methods, we can create a clean resource with no code duplication.

The Good Stuff: Use helper functions to organize your Class-Based resources.

Read More

Creating A DSC Class-Based Resource

Now that we know what a PowerShell class is, it’s time we start putting them to use. Classes are new with version 5 and one of the best places for them is DSC. While the syntax maybe different, all the DSC concepts are the same. If you need a refresher on the basics of a PowerShell class, please see my previous post, Intro to PowerShell Classes.

The Good Stuff:

How to create a DSC Class-Based Resource.

Read More

Introduction To PowerShell Classes

This is going to be the first in a series of posts regarding classes. I want to talk more about DSC and especially some of the cool things you can do with class based resources. Before we get to the advanced use cases, we need to cover the basics.

The Good Stuff: An introduction to PowerShell classes.

Read More

A Real World Pester Example From the PowerShell Github

A hobby of my mine is to peruse the PowerShell Github page for open issues and pull requests. Its a direct way to interact with the team, see what features are being worked on and actually make a difference. I understand that putting yourself out there can be scary but everyone is incredibly friendly and its a great place to get constructive feedback. Aren’t that good at C#? Add some documentation or a Pester test. Anything helps and there’s a ton to do.

The Good Stuff: Go to the PowerShell Github Page and start contributing!

Read More

Working With Plaster

If you haven’t yet, I would definitely check out Plaster. Plaster is a PowerShell scaffolding module. What that means for you is that its an easy way to keep your modules and functions consistent and following best practices. Its fully customizable and you can get started in just a few minutes.

The Good Stuff:

Go check out plaster, a template-based file and project generator written in PowerShell. Plaster Project Page

Read More

Getting Some Random Help?

I think one of the biggest hurdles learning PowerShell is trying to find what command to run. What i use to do is read a different help file every morning. Now i don’t expect anyone to be able to look at a help file once and instantly know the ins and outs of a command. But forcing yourself to read a random help file can get the mental juices flowing. The goal of this script is to just start learning what PowerShell CAN do.

The Good Stuff: A script to get a random help file. Open-PSCommandHelp.ps1.

Read More

Adding Sudo to PowerShell

Lets be honest, before PowerShell the windows command line was a joke and the Linux guys were running circles around us. One of the best functions from Linux is sudo. Sudo is used when you need to run a command with elevated privileges, similar to running a program as administrator in windows. Here’s my implementation of sudo for PowerShell.

The Good Stuff: A script that implements sudo in Powershell. Start-ElevatedProcess.ps1

Read More