Created
October 23, 2019 14:39
-
-
Save IISResetMe/28af46b613cd513473bf63af703ecc57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Management.Automation; | |
namespace MyCmdlets | |
{ | |
[Cmdlet(VerbsData.Merge, "Object")] | |
public class MergeObjectCommand : PSCmdlet | |
{ | |
[Parameter(ValueFromPipeline = true, Mandatory = true)] | |
public PSObject[] InputObject; | |
private List<PSObject> objects; | |
protected override void BeginProcessing() | |
{ | |
objects = new List<PSObject>(); | |
} | |
protected override void ProcessRecord() | |
{ | |
foreach (var obj in InputObject) | |
objects.Add(obj); | |
} | |
protected override void EndProcessing() | |
{ | |
// do work on this.objects here | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment