Skip to main content

Working with Script Blocks

  • Chapter
Pro Windows PowerShell
  • 1662 Accesses

Abstract

The PowerShell programming language is very dynamic. Until now, I have focused on its abilities to manipulate objects of any kind. In this chapter, we will explore my favorite language feature: script blocks. Blocks help craft elegant code not only when manipulating collections of objects but in many other situations. Most importantly, script blocks allow us to encapsulate pieces of code and delay their execution. Script blocks are containers holding pieces of code that do not have to be assigned a formal name. We can create them dynamically in the middle of any script operation, and, of course, we can execute them multiple times, passing different parameters.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 49.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Rights and permissions

Reprints and permissions

Copyright information

© 2008 Hristo Deshev

About this chapter

Cite this chapter

(2008). Working with Script Blocks. In: Pro Windows PowerShell. Apress. https://doi.org/10.1007/978-1-4302-0546-3_4

Download citation

Publish with us

Policies and ethics