O'Reilly logo

PowerShell in Depth: An administrator's guide by Don Jones, Richard Siddaway, and Jeffery Hicks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 22. Scope

This chapter covers

  • Understanding scope
  • Using scope
  • Using best practices

Scope is one of the most confusing things about PowerShell when you’re a newcomer, and even experienced gurus get tripped up by it from time to time. If you’re just using the shell as a shell—meaning you’re running commands and seeing the results onscreen—then scope won’t affect your life much. It’s when you start writing scripts, functions, and modules that scope comes into play.

22.1. Understanding scope

Scope is a form of containerization. Certain elements in PowerShell are considered scoped elements, and when you create one it only exists within the container, or scope, in which you created it. Generally speaking, it can only be used from within ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required