首先编写程序自定义功能
该程序引用了一个System.Management.Automation.dll,该dll在C:\Windows\assembly\GAC_MSIL\System.Management.Automation\1.0.0.0__31bf3856ad364e35文件夹下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading.Tasks;
namespace PSBook.Chapter2
{
[Cmdlet(VerbsCommunications.Write, "Hello")]
public class SayHello : Cmdlet
{
protected override void ProcessRecord()
{
WriteObject("Hello,world");
}
}
[Cmdlet(VerbsCommunications.Write,"Hi")]
public class SayHi : Cmdlet
{
protected override void ProcessRecord()
{
WriteObject("Hi,world");
}