Pergunta

I'm pretty new to powershell. I've built a custom cmdlet. I already have it registered in powershell but i wanted to test it before i started using the cmdlet. So i added a simple testapp to my solution. I'm trying to call my custom cmdlet like the following:

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

I set a break point in my cmdlet and when i execute .invoke it never does anything. The only method i'm overriding in my cmdlet is "ProcessRecord" but when i call invoke its never does anything. I'm sure its something simple. Does anyone know what i'm doing wrong?

Foi útil?

Solução

Calling .Invoke() returns an IEnumerator ... you have to iterate it (e.g. call MoveNext()) in order for the cmdlet to actually get invoked. See the remarks on the MSDN docs page

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top