mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Add cmdlet example project with readme
This commit is contained in:
1 parent
aa95479307
commit
07a615e283
4 files changed
+185
No files matched your search
@@ -0,0 +1,30 @@
|
||||
// Example from https://msdn.microsoft.com/en-us/library/dd901838(v=vs.85).aspx
|
||||
|
||||
using System.Management.Automation; // Windows PowerShell assembly.
|
||||
|
||||
namespace SendGreeting
|
||||
{
|
||||
// Declare the class as a cmdlet and specify and
|
||||
// appropriate verb and noun for the cmdlet name.
|
||||
[Cmdlet(VerbsCommunications.Send, "Greeting")]
|
||||
public class SendGreetingCommand : Cmdlet
|
||||
{
|
||||
// Declare the parameters for the cmdlet.
|
||||
[Parameter(Mandatory=true)]
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
private string name;
|
||||
|
||||
// Overide the ProcessRecord method to process
|
||||
// the supplied user name and write out a
|
||||
// greeting to the user by calling the WriteObject
|
||||
// method.
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
WriteObject("Hello " + name + "!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user