Chapter 22. Creating Cmdlets

WHAT'S IN THIS CHAPTER?

  • Using cmdlets effectively

  • Using the Make-Shell utility to create a shell extension

  • Creating a basic cmdlet

Scripting works fine for a wide variety of needs. However, just as an interpreted language doesn't always provide what's needed for a successful application, scripts sometimes fall short, too. When this occurs, you really need to have something compiled, which in Windows PowerShell is a cmdlet. There's a balance you must consider when deciding between scripts and cmdlets, so that's the first topic this chapter covers.

Writing a basic cmdlet isn't much different from writing a typical application. There are some special rules you need to follow, however, and this chapter discusses them. The biggest change you'll notice is that cmdlets aren't directly usable from the command line. You must make them part of the Windows PowerShell shell in order to use them, which requires the use of a special utility. This chapter discusses the entire process for creating and using a cmdlet successfully in Windows PowerShell.

UNDERSTANDING WHEN TO USE CMDLETS

Cmdlets have some significant advantages over scripts. They're the best solution for many practical needs. The following list describes some of the best uses for cmdlets. Of course, you'll probably be able to come up with a few of your own reasons for using them as well.

  • Application interfaces: Although there aren't a lot of applications that currently rely on cmdlets, there are some out there ...

Get Professional Windows 7 Development Guide 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.