Does calling a custom cmdlet not work?

I am new to powershell. I created my own cmdlet. I already registered it with PowerShell, but I wanted to test it before I started using the cmdlet. So I added a simple testapp for my solution. I am trying to invoke my own cmdlet as follows:

var deploy = new DeployCommand(); deploy.BranchDir = @""; deploy.DevDir = @"d:\sandbox\testdeploy"; deploy.Invoke(); 

I set a breakpoint on my cmdlet, and when I execute .invoke, it never does anything. The only method I override in my cmdlet is ProcessRecord, but when I call it, it never does anything. I am sure this is something simple. Does anyone know what I'm doing wrong?

+4
source share
1 answer

Calling .Invoke () returns an IEnumerator ... you need to repeat it (for example, call MoveNext ()) so that the cmdlet is actually called. See Notes on the MSDN Documents page.

+6
source

All Articles