Recent deployments of powershell don’t come with this assembly, which you need to write cmdlets in C#.
You need to install the powershell 2.0 sdk and look for:
$(ProgramFiles)Reference AssembliesMicrosoftWindowsPowerShellv1.0System.Management.Automation.dll
Here is a simple cmdlet:
using System.Management.Automation;
namespace SimpleGreeting
{
[Cmdlet(VerbsCommunications.Send, “Greeting”)]
public class SendGreetingCommand : Cmdlet
{
[Parameter(Mandatory=true)]
public string Name { get; set; }
protected override void ProcessRecord()
{
WriteObject(“Hello” + Name + “!”);
}
}
}
And here is the installer required:
using System.Management.Automation;
using System.ComponentModel;
namespace SimpleGreeting
{
[RunInstaller(true)]
public class RegisterSimpleGreeting : PSSnapIn
{
public override string Description
{
get { return “This is a demo snapin”; }
}
public override string Name
{
get { return “SendGreetingSnapin”; }
}
public override string Vendor
{
get { return “C.J Eyre Harlequin Design”; }
}
}
}
You need to use installutil to register the snapin.