Initialize a Byte Array in PowerShell

Sometimes you’ll need to initialize a new buffer as an array of bytes. For example, if you want to generate random data using the NextBytes() method on the System.Random class,  you need to pass in a byte array buffer for the method to write to. Creating a byte array in …

Continue reading

Keep AWS PowerShell Module Updated on Mac OS

Are you on Mac OS and need to keep your AWS PowerShell module up-to-date? As you’ve probably noticed, there are frequently new versions of the AWS PowerShell module being released, to keep pace with new services and service features being added to Amazon Web Services (AWS) cloud. Updating PowerShell modules …

Continue reading

PowerShell Intellisense: ScriptBlock Handler Parameters

I keep forgetting the names of the parameters that are passed into the ScriptBlock handlers for PowerShell Intellisense (aka. tab-completion / auto-completion). Hence, I’m posting the list of parameters here, along with a simple example. $commandName – the name of the PowerShell command that Intellisense was invoked for. $parameterName – …

Continue reading

CloudFormation YAML: EC2 Instance with PowerShell UserData

Someone recently was asking for an AWS CloudFormation template, in YAML format as opposed to JSON, that would deploy an EC2 instance running Windows Server, and supported a PowerShell-based UserData script. In response to this, I created the YAML snippet below. Note that the Amazon Machine Image (AMI) ID is …

Continue reading

Restore Default PowerShell Gallery Repository

If you’ve accidentally deleted the PowerShell Gallery (PSGallery) repository from your system, you can restore it using the following command. Register-PSRepository -Default In fact, if you try to re-register the PowerShell Gallery using the same method that you’d register a custom repository (see below) … $Repository = @{ Name = …

Continue reading

Retrieve AWS AccountID using PowerShell

As an AWS customer writing programs against AWS service APIs, using the AWS Tools for PowerShell, you’ll often need to reference your AWS AccountID. For example, some service API calls require passing in an Amazon Resource Name (ARN), which contains your AWS AccountID as one of its parts. Much of …

Continue reading

Amazon EC2 Instances Will Support Per-Second Billing

In an exciting, new announcement on their blog, Amazon Web Services (AWS) has just announced that EC2 Instances running Linux, and “are launched in On-Demand, Reserved, and Spot form,” will support per-second billing. This includes AWS Batch and Elastic Map Reduce (EMR). Since 2006, when EC2 was launched, EC2 Instances were …

Continue reading

Change VSCode Integrated Terminal to PowerShell

Visual Studio Code :: Integrated Terminal Setting

Visual Studio Code is an excellent developer tool for PowerShell projects. However, regardless of which type of project you’re developing (C#, Node.js, Python, etc.), you can benefit from changing your default shell to the powerful, object-oriented PowerShell shell. Now, you may not want to change your default shell for the …

Continue reading

Why I use Visual Studio Code to write PowerShell

Visual Studio Code - PowerShell Extension

A Little History on PowerShell Editors Since 2009, PowerShell users have been rewarded with an improvement over Notepad, for authoring PowerShell scripts and modules. That tool is called the PowerShell Integrated Scripting Editor (ISE), which was originally included out-of-box with Windows 7 and PowerShell version 2.0. Over the years, PowerShell …

Continue reading