Blog

Viewing posts for the category PowerShell

Ship Assemblies Inside Your PowerShell

This code generates a function that will load the assembly into the current PowerShell session. Yes it's a dumb idea but when your team lead tells you "we can't copy a dll file to every server your script needs to run on.", this is what happens.

Reading and Writing GZip Files With PowerShell

#Requires -Version 4

Creating Zero Filled Files with PowerShell

There are times where you'd like to create a dummy file for testing, if you're on Windows you may be familiar with the 'fsutil file createnew' command. This allows you to create a zero filled file of a predefined size, fantastic. It's a small, but powerful, command that is included with every Windows install but let's assume you need a PowerShell native method for creating a zero filled file, what might that look like?

Powershell Live Code Loading (kind of)

Hot code loading is a feature of languages that allows a developer to load new code into a running system without stopping the process. This has some clear benefits on servers, security and feature patches can be added without a risk of downtime. Yes, building your application in a way that you can fail over to a secondary system but that never seemed kosher to me as a patching strategy unless you're working at scale and already account for high availablity. I've implemented some long runner server software in PowerShell and using some of the features it's gleaned from Unix scripting you can hot load new code into them on the fly.