-
Notifications
You must be signed in to change notification settings - Fork 33
/
InvokeTemplateCmdletCommand.cs
52 lines (44 loc) · 1.15 KB
/
InvokeTemplateCmdletCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.ComponentModel;
using System.Management.Automation;
/*
To build and install:
1) Set-Alias csc $env:WINDIR\Microsoft.NET\Framework\v2.0.50727\csc.exe
2) $ref = [PsObject].Assembly.Location
3) csc /out:TemplateBinaryModule.dll /t:library InvokeTemplateCmdletCommand.cs /r:$ref
4) Import-Module .\TemplateBinaryModule.dll
To run:
PS >Invoke-TemplateCmdlet
*/
namespace Template.Commands
{
[Cmdlet("Invoke", "TemplateCmdlet")]
public class InvokeTemplateCmdletCommand : Cmdlet
{
[Parameter(Mandatory=true, Position=0, ValueFromPipeline=true)]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
private string text;
protected override void BeginProcessing()
{
WriteObject("Processing Started");
}
protected override void ProcessRecord()
{
WriteObject("Processing " + text);
}
protected override void EndProcessing()
{
WriteObject("Processing Complete.");
}
}
}