Chapter 20. The PowerShell and runspace APIs

 

This chapter covers

  • The PowerShell Application Programming Interface (API)
  • How to perform isolated and concurrent operations
  • Runspaces and runspace pools
  • Out-of-process and remote runspaces
  • Basic runspace management techniques

Here’s a rule I recommend: never practice two vices at once.

Tallulah Bankhead

So far, we’ve been dealing with PowerShell as a shell and scripting environment. In this chapter, we’re going to look at it as an Application Programming Interface (API). An API is a set of functions, data structures, and classes that let you build applications on top of the software exposing that API. For example, the PowerShell ISE is an application that uses the PowerShell API. Normally, the PowerShell API is used by other programs for accessing PowerShell functionality, but it also turns out to be useful from within PowerShell itself. In effect, PowerShell scripts can act as host applications for other PowerShell engine instances, allowing you to perform advanced operations like dynamic pipeline construction, isolated execution, and concurrent operations.

20.1. PowerShell API basics

In this section, we’ll look at the basic use patterns and structure of the PowerShell API. We’ll look at how to construct instances of the core API objects and how to compose those objects into executable pipelines.

20.2. Runspaces and the PowerShell API

20.3. Runspace pools

20.4. Out-of-process runspaces

20.5. Remote runspaces

20.6. Managing runspaces

20.7. Summary

sitemap