Script Blocks

This bit…  gives us the ability to save in a script block in a variable i.e.

$bigfiles = {
dir -Recurse | Where {$_.Length -gt 10000000}
}

To execute the script block just add a ‘&’ as prefix for the variable name

&$bigfiles

In this case, a list of all files larger than 10000000bytes under the current direcory will be returned.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.