So, what is PowerShell 3.0 WMI?

Exclusive offer: get 50% off this eBook here
Instant Windows Powershell 3.0 Windows Management Instrumentation Starter [Instant]

Instant Windows Powershell 3.0 Windows Management Instrumentation Starter [Instant] — Save 50%

Explore new abilities of Powershell 3.0 to interact with Windows Management Instrumentation (WMI) through the use of the new CIM cmdlets and realistic management scenarios with this book and ebook.

$19.99    $10.00
by Brenton J.W. Blawat | September 2013 | Enterprise Articles Microsoft

In this article, by Brenton J.W. Blawat, the author of "Instant Windows PowerShell 3.0 Windows Management Instrumentation Starter, we learn how PowerShell 3.0 utilizes Windows Management Instrumentation (WMI).

(For more resources related to this topic, see here.)

Microsoft created Windows Management Instrumentation ( WMI ) as a management layer to the Windows operating system. This management layer allows you to retrieve information pertaining to the operating system or physical hardware on a system. It also allows you to manipulate components within the operating system.

A good example for this section is a hard drive. WMI provides the ability to view the physical hard drive as well as the logical components of the hard drive. Using a call to the Win32_diskdrive class, you have the ability to view the physical aspects of the disk drive, such as the tracks, sectors, manufacturer, and even the serial number. The win32_logicaldisk class provides you with the ability to see the logical aspects of a drive, such as partitions, free space, and volume names.

Not limited to just Windows operating system management, WMI also has the extensibility to allow third-party developers to create WMI providers for use within their projects. This means that you can create the management hooks within your code that will allow remote management through a common standardized framework. Many companies have adopted the use of WMI providers for items such as storage subsystems, application virtualization, hardware virtualization, and enhanced management of the hardware connected to a workstation or server system.

Microsoft chose to follow the Common Information Model ( CIM ) industry standard for WMI. The preceding diagram takes a simplified look at Microsoft's implementation of WMI through the use of the CIM standard. There are three layers to their model, which are as follows:

  • WMI consumers: The WMI consumers are exactly what their name states. They consume the available APIs to access the managed component. The WMI consumers are the real users of the C/C++ and .NET clients, and they use scripting languages, such as PowerShell 3.0, to access management data and interact with the managed components. In the hard drive example, the WMI consumer is the PowerShell code that calls information about the hard drive. This would look as follows:

    get-wmiobject –class win32_logicaldisk

  • WMI infrastructure: The WMI infrastructure includes the CIM Object Manager ( CIMOM ), which stores a repository of the available WMI providers. If a third-party WMI provider doesn't register with the CIM Object Manager, the Windows operating system will not be able to manage the component through WMI. In the hard drive example, the CIMOM will import the Managed Object Format ( MOF) file of the hard drive into the WMI repository. This will register the hard drive's available WMI properties and methods into use by a WMI consumer.
  • WMI providers: The last components, WMI providers, are made up of a driver (DLL) and a MOF file. These two components are responsible for returning the management data to the WMI consumer, through the WMI infrastructure. This allows the WMI consumer to interact with the managed components. In the hard drive example, the WMI consumer will access the hard drive through the WMI infrastructure utilizing the hard drive driver (DLL). The WMI consumer will have the ability to retrieve the information pertaining to the physical components on that hard drive.

WMI integration with PowerShell 3.0

PowerShell has the ability to interact with WMI through the use of the built-in cmdlets. These cmdlets act as the WMI consumers and interact with the WMI. As WMI evolved with the release of new operating systems, PowerShell also needed to evolve in parallel to manage those systems. With the release of Windows 8 and Windows Server 2012, Microsoft created a new iteration of the Microsoft Windows Management Framework ( WMF ), Version 3.0. The new release of Windows Management Framework updates WMI to Version 3.0, PowerShell to Version 3.0, and installs the new Windows Remote Management ( WinRM ), OData IIS Extensions, and Server Manager CIM Provider.

PowerShell 3.0 includes new WMI management cmdlets, displayed in the following table, which leverage the use of the new functionality within Windows Management Framework 3.0. The new CIM cmdlets provide a richer WMI experience leveraging stateful communications to the remote systems. They also provide the ability to create CIM calls through PowerShell 3.0 to non-Windows-based WMI systems that support Web Services-Management ( WSman ). This provides engineers the ability to tap into a variety of systems for management purposes.

Get-CimAssociatedInstance

New-CimSession

Get-CimClass

New-CimSessionOption

Get-CimInstance

Register-CimIndicationEvent

Get-CimSession

Remove-CimInstance

Invoke-CimMethod

Remove-CimSession

New-CimInstance

Set-CimInstance

Using PowerShell in your environment

PowerShell is quickly becoming the de-facto standard for managing the Windows-based systems in small and large organizations. It is being used for tasks, such as automated software deployments, dynamic system provisioning, and system maintenance. It is also being heavily used in Microsoft products, such as System Center 2012 - Service Manager, that allow for business process automation.

PowerShell 3.0 has introduced a variety of new cmdlets that further simplify the administration of systems through the use of WMI. Whatever the administrative task, the PowerShell community has several examples of the ways to manage systems through the use of the WMI consumers.

The examples provided in this article are just the tip of the iceberg compared to what you can accomplish utilizing PowerShell 3.0 and Windows Management Instrumentation. You may be surprised by the number of manual administration steps that can be automated by creating PowerShell scripts. The sky is the limit when it comes to scripting with PowerShell!

Summary

In this article, we learned what Windows Management Instrumentation (WMI) is, how PowerShell 3.0 utilizes it, and why it's applicable to systems engineers.

Resources for Article :


Further resources on this subject:


Instant Windows Powershell 3.0 Windows Management Instrumentation Starter [Instant] Explore new abilities of Powershell 3.0 to interact with Windows Management Instrumentation (WMI) through the use of the new CIM cmdlets and realistic management scenarios with this book and ebook.
Published: March 2013
eBook Price: $19.99
See more
Select your format and quantity:

About the Author :


Brenton J.W. Blawat

Brenton Blawat has been a successful entrepreneur, strategic technical advisor, and engineer who has a passion for the procurement of technology in organizations. He is business-centric, while being technology-minded, and has had many years of experience bridging the gap between technical staff and decision makers in organizations. Brenton prides himself on his ability to effectively communicate to a diverse audience and provide strategic direction for small and large organizations alike. Throughout his career, he has worked for a multitude of Fortune 500 organizations, and specializes in delivery automation and workflow optimizations.

Books From Packt


PowerShell 3.0 Advanced Administration Handbook
PowerShell 3.0 Advanced Administration Handbook

SQL Server 2012 with PowerShell V3 Cookbook
SQL Server 2012 with PowerShell V3 Cookbook

Microsoft Windows PowerShell 3.0 First Look
Microsoft Windows PowerShell 3.0 First Look

 Microsoft SharePoint 2010 Developer’s Compendium: The Best of Packt for Extending SharePoint
Microsoft SharePoint 2010 Developer’s Compendium: The Best of Packt for Extending SharePoint

Microsoft SharePoint 2010 and Windows PowerShell 2.0: Expert Cookbook
Microsoft SharePoint 2010 and Windows PowerShell 2.0: Expert Cookbook

Microsoft Exchange 2010 PowerShell Cookbook
Microsoft Exchange 2010 PowerShell Cookbook

Windows Server 2012 Hyper-V Cookbook
Windows Server 2012 Hyper-V Cookbook

Instant Oracle Database and PowerShell How-to [Instant]
Instant Oracle Database and PowerShell How-to [Instant]


No votes yet

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
M
w
T
Q
C
S
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software