Chapter 18. Your own WMI cmdlets

 

This chapter covers

  • Creating cmdlets from WMI classes
  • Creating a module to load multiple cmdlets
  • Creating format and type files

In the previous 17 chapters of the book, you’ve seen how to use the WMI cmdlets provided in PowerShell v2. PowerShell v3, introduced with Windows 8, enables you to take this a step further and create your own WMI cmdlets! The ability to create cmdlets directly from the WMI classes will radically alter the way we work with WMI in the future. This functionality is referred to as cmdlets-over-objects—you create a cmdlet directly from the WMI object. The use of WMI and CIM is massively expanded in the Windows 8 product line. In fact, much of the new PowerShell functionality introduced in the Windows 8 family is cmdlets produced directly from WMI classes.

In one respect, this makes our job easier, because we have a lot of new functionality out of the box, but in another respect it makes things more difficult, as we have new technologies and concepts to learn. This chapter and the next will show how it all works, when you should use the new options, and when you should stick with the traditional ways.

Figure 18.1. Using the Win32_OperatingSystem class to display data, including boot time
Warning

This material is based on beta versions of PowerShell v3, and there may be changes between the time of writing and the release of Windows 8 and PowerShell v3.

18.1. Creating a WMI cmdlet

18.2. Creating multiple cmdlets

18.3. Creating format and type files

18.4. Using the CIM IDE

18.5. Summary

sitemap