2

I am using a C# library (.NET 4) with the System.Management.Automation DLL file to implement some commands for PowerShell (2.0).

I need to get a value from a command in a PowerShell script.

[Cmdlet(VerbsCommon.Get, "MyCommand")]
public class GetMyCommand : Cmdlet
{
    protected override void ProcessRecord()
    {
        // How do I return a value to PowerShell?
    }
}

The way I would like to get a value is something like this:

$value = Get-MyCommand

1 Answer 1

2

You have to use the CmdLet.WriteObject method.

Here is a good explanation from @RomanKuzmin.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.