My Profile Photo
name := "Graham Beer"

`Cloud Engineer with his head in the AWS clouds, authored chapters in the PowerShell Conference Book 1 & 2 and currently learning and enjoying Go


PowerShell Conf Book Planet PowerShell Top 50 PowerShell

The PowerShell scriptblock

The scriptblock is a fundamental feature of the PowerShell language. Understanding the different ways to use scriptblocks is essential to for the advanced PowerShell developer.

What is a scriptblock?
A scriptblock is a block of script code that exists as an object reference but does not require a name. To write a scriptblock we add a piece of code is encapsulated by curly braces {}. Scriptblocks are effectively containers that hold code and allow us to delay their execution. We use scriptblocks for a lot of tasks we do in PowerShell. Consider the following: Where, Foreach, While, Do, to name a few. But we can use scriptblocks for many other cases.

4sysops article continues hereā€¦