Datasheet

UNDERSTAND HOW POWERSHELL AND ACTIVE DIRECTORY WORK TOGETHER 49
Administering
Service Delivery
PART I
“Con guring Active Directory Dependencies,” we’ll look at how to automate DNS.
e majority of the ways you’ll interact with DNS will use WMI.
WMI Basics
WMI provides an object-oriented way to manage Windows. WMI uses the con-
cept of classes, which de ne di erent types of objects that WMI can interact with.
Similar to how .NET classes work, WMI provides methods (pieces of executable
code) and properties.
Windows provides a series of classes out of the box for interacting with core Windows
components. For example, the
Win32_Service
class provides a way to interact
with Windows services.  e methods in the class allow you to do things like start
or stop a service, while the properties de ne the di erent attributes of the service,
such as its name.
Several classes are packaged together to form namespaces. Namespaces can
be provided by both Microso applications and third-party applications. is
speaks to the extensibility of WMI and is one of the reasons why WMI is so
widely used not only in PowerShell scripting, but in other scripting languages
as well.  e Windows operating system places its core classes in the namespace
root\cimv2
.
WMI also uses instances. An instance is an instantiation (an actual object) of a
class. For example, if you have 20 services running on your computer, then you have
20 instances of the
Win32_Service
class. You can connect to each instance (each
service) and modify it or perform one of its methods.
Another thing you should know about WMI is that there is a query language built
around it. You can use this WMI Query Language (WQL) to search for WMI
instances. Without WQL, you would have to list the instances of a class and then
enumerate through each instance to  nd the one you want. With WQL, you can
search for that particular instance and work with it directly.
WMI PowerShell Cmdlets
PowerShell can interact with WMI in a couple of di erent ways. Similar to
how PowerShell uses ADSI to interact with Active Directory, there is a WMI pro-
vider.  is allows you to use the following method of interacting with WMI:
$objReg = [WMICLASS]”\\.\root\cimv2:StdRegProv”
c01.indd 49c01.indd 49 5/12/2011 1:07:57 PM5/12/2011 1:07:57 PM