module/src/InvokeCbsDnsQueryCmdlet.cs

using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.Net;
using DnsClient;
using System.Management.Automation;
 
[Cmdlet("Invoke", "CbsDnsQuery")]
public class InvokeCbsDnsQueryCmdlet : PSCmdlet {
 
    [Parameter(
        Position = 0,
        Mandatory = true,
        ValueFromPipeline = true,
        ValueFromPipelineByPropertyName = true
    )]
    public string Hostname;
 
    [Parameter(Position = 1)]
    public QueryType QueryType = QueryType.A;
 
    LookupClient Client;
 
    protected override void BeginProcessing() {
        Client = new LookupClient();
    }
 
    protected override void ProcessRecord() {
        try {
            WriteObject(Client.Query(Hostname, QueryType));
        } catch (Exception ex) {
            WriteError(new ErrorRecord(ex, "Query failed", ErrorCategory.ReadError, this));
        }
    }
}