using System.Management.Automation; namespace HelloPowerShell { [Cmdlet(VerbsCommon.Get, "HelloCmdlet")] public class HelloCmdlet : Cmdlet { protected override void ProcessRecord() { WriteObject("Hello World!"); } } }
<?xml version="1.0" encoding="utf-8" ?> <helpItems xmlns="http://msh" schema="maml"> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> hellocmdlet </command:name> <maml:description> <maml:para>hellocmdlet</maml:para> </maml:description> <maml:copyright> <maml:para>Copyright</maml:para> </maml:copyright> <command:verb></command:verb> <command:noun></command:noun> </command:details> <maml:description> <maml:para> hellocmdlet description </maml:para> </maml:description> </command:command> </helpItems>
using System.Collections.ObjectModel; using System.ComponentModel; using System.Management.Automation; using System.Management.Automation.Runspaces; namespace HelloPowerShell { [RunInstaller(true)] public class HelloSnapIn : CustomPSSnapIn { private Collection<CmdletConfigurationEntry> _cmdlets; /// <summary> /// Gets description of powershell snap-in. /// </summary> public override string Description { get { return "A Description of HelloCmdlet"; } } /// <summary> /// Gets name of power shell snap-in /// </summary> public override string Name { get { return "HelloCmdlet"; } } /// <summary> /// Gets name of the vendor /// </summary> public override string Vendor { get { return ""; } } public override Collection<CmdletConfigurationEntry> Cmdlets { get { if (null == _cmdlets) { _cmdlets = new Collection<CmdletConfigurationEntry>(); _cmdlets.Add(new CmdletConfigurationEntry ("Get-HelloCmdlet", typeof(HelloCmdlet), "Get-HelloCmdlet.dll-Help.xml")); } return _cmdlets; } } } }
.Net (3) ASP.Net (6) ASP.Net MVC (3) Best Practice (2) Book (3) Burn CD/DVD (1) C# (3) Career (1) Class Library (1) Community event (9) Design (1) Design Patterns (1) Ethernet (1) Home Network (1) i18n (1) Internet Explorer (1) iPod (1) JavaScript (2) jQuery (1) Library (1) Microsoft Translator (1) Ms Office (1) MVC Unit test (1) NWMTUG (4) Open Source (2) PowerShell (13) SharePoint (1) Team System (1) Test Driven Development (7) Utility (13) Visual C++ (1) Visual Studio 2008 (11) Windows 64 bit (1) Windows 7 (9) Windows XP (3)