Fanr

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

工具:VS 2010,.Net 3.5(特别提示.net 4不支持)

环境:PS V2,Windows 7

 

using System;
using System.Collections.Generic;
using System.Text;
using System.Management.Automation;
using System.Collections;
using System.Management;
using System.Collections.ObjectModel;

namespace Snapin
{
[Cmdlet(VerbsCommon.Get, "Hi")]
public class Snapin : PSCmdlet
{

protected override void ProcessRecord()
{
try
{
string str = "Hello Snapin";
WriteObject(str, false);
}
catch (Exception)
{
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Management.Automation;
namespace Snapin
{
[RunInstaller(true)]
public class SnapinPSSnapIn : PSSnapIn
{

public override string Name
{
get { return "SnapinHello"; }
}
public override string Vendor
{
get { return "Fanr"; }
}
public override string VendorResource
{
get { return "SnapinHello,Fanr"; }
}
public override string Description
{
get { return "Registers the CmdLets and Providers in this assembly"; }
}
public override string DescriptionResource
{
get { return "Snapin,Registers the CmdLets and Providers in this assembly"; }
}
}
}



posted on 2011-11-16 23:22  Fanr_Zh  阅读(688)  评论(0编辑  收藏  举报