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?