Skip to content

Instantly share code, notes, and snippets.

@tanaka-takayoshi
Created March 2, 2014 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanaka-takayoshi/9309470 to your computer and use it in GitHub Desktop.
Save tanaka-takayoshi/9309470 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading.Tasks;
namespace MyCmdlets
{
[Cmdlet(VerbsCommon.Get, "Greeting")]
public class GetGreeting : Cmdlet
{
[Parameter(Position = 0, ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]
public string Name { get; set; }
[Parameter(Position = 1)]
[ValidateSet("さん", "様", "殿")]
public string Title { get; set; }
protected override void BeginProcessing()
{
WriteObject("Begin Hello World!");
}
protected override void ProcessRecord()
{
WriteObject(Name + " " + Title);
}
protected override void EndProcessing()
{
WriteObject("End Hello World!");
}
protected override void StopProcessing()
{
//出力されない
WriteObject("Now stopping...");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment