Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
Created October 23, 2019 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IISResetMe/28af46b613cd513473bf63af703ecc57 to your computer and use it in GitHub Desktop.
Save IISResetMe/28af46b613cd513473bf63af703ecc57 to your computer and use it in GitHub Desktop.
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