Chapter 30. PowerShell Basics
The goal of this chapter is to give you a basic understanding of what Windows PowerShell is, how it can help you, and a quick reference source for PowerShell constructs. We’ll take a look at the PowerShell language, the built-in cmdlets, and how to integrate PowerShell with technologies like WMI.
PowerShell is more than just a shell. It’s a scripting platform, a programming language, a development environment, and a replacement for the legacy Windows command shell, cmd.exe. Automation is a key facet of running a successful IT operation, and Windows PowerShell extends the ability to automate across numerous Microsoft and third-party technologies in an easy and cohesive manner.
Exploring the PowerShell
As with any shell, PowerShell has a number of basic features that you should be familiar with as you move through this chapter.
Variables and Objects
Variables are named data storage that you can
use in PowerShell to store whatever you want. Variables are always
prefixed with a $
sign followed by a
name of your choosing. For example, if you wanted to store
Brian in a variable called $FirstName
, you would run $FirstName = "Brian"
.
Variables also have scope. Scope determines which level of access is provided to variables (and also functions) within the PowerShell environment. Table 30-1 details the three possible scopes for your variables. You need to remember scope when you start working with scripts and functions as you may find that variables you were looking ...
Get Active Directory, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.