Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

Cmdlet Samples

This section includes sample code that is provided by Windows PowerShell. You can copy the code from the topics in this section, or download the source files from the Download Center. The Download Center provides ReadMe files, source files, and Visual Studio project files for each sample.

In This Section

GetProcessSample01 Sample
This sample shows how to write a cmdlet that retrieves the processes on the local computer.

GetProcessSample02 Sample
This sample shows how to write a cmdlet that retrieves the processes on the local computer. It provides a Name parameter that can be used to specify the processes to be retrieved.

GetProcessSample03 Sample
This sample shows how to write a cmdlet that retrieves the processes on the local computer. It provides a Name parameter that can accept an object from the pipeline or a value from a property of an object whose property name is the same as the parameter name.

GetProcessSample04 Sample
This sample shows how to write a cmdlet that retrieves the processes on the local computer. It generates a nonterminating error if an error occurs while retrieving a process.

GetProcessSample05 Sample
This sample shows a complete version of the Get-Proc cmdlet.

StopProcessSample01 Sample
This sample shows how to write a cmdlet that requests feedback from the user before it attempts to stop a process, and how to implement a PassThru parameter that indicates that the user wants the cmdlet to return an object.

StopProcessSample02 Sample
This sample shows how to write a cmdlet that writes debug, verbose, and warning messages while stopping processes on the local computer.

StopProcessSample03 Sample
This sample shows how to write a cmdlet whose parameters have aliases and that support wildcard characters.

StopProcessSample04 Sample
This sample shows how to write a cmdlet that declares parameter sets, specifies the default parameter set, and can accept an input object.

Events01 Sample
This sample shows how to create a cmdlet that allows the user to register for events raised by FileSystemWatcher. With this cmdlet users can, for example, register an action to execute when a file is created under a specific directory. This sample derives from the ObjectEventRegistrationBase base class.

See Also



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.