Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
April 14, 2022

Creating Basic Functions

In a previous post, we looked at creating and using script blocks in PowerShell. As you’ll discover, these are the building blocks of PowerShell functions. Script blocks are a simple way of “packaging” re-usable PowerShell code. However, invoking them can get a bit awkward, especially as the script block grows in complexity. On the other hand, functions are much easier to write and use. Eventually, I’ll show you how to write functions that are indistinguishable from compiled cmdlets. But for now, we’ll start with a basic PowerShell function.

Script Block to Function

Let’s begin with a script block that will use Get-CimInstance to examine classic Windows event logs and report on utilization.

Want to read the full issue?
GitHub Bluesky LinkedIn About Jeff
Powered by Buttondown, the easiest way to start and grow your newsletter.