title: What is '<Invoke>d__40'?
body: <p>Using Powershell, System.Management.Automation.Cmdlet.Invoke() returns object of type <code>'&lt;Invoke&gt;d__40'</code> rather than specified OutputType.</p>
  <p>To reproduce:</p>
  <ol>
  <li>Copy <a href="https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/how-to-write-a-simple-cmdlet?view=powershell-5.1#example" rel="nofollow noreferrer">SendGreeting example cmdlet</a> to .\ExampleCmdlet.cs</li>
  <li><code>powershell -NoProfile</code></li>
  <li><code>Add-Type -Path .\ExampleCmdlet.cs</code></li>
  <li><code>$command = [SendGreeting.SendGreetingCommand]::new()</code></li>
  <li><code>$command.Name = 'Person'</code></li>
  <li><code>$invoke = $command.Invoke()</code></li>
  <li><code>$invoke.GetType()</code></li>
  </ol>
  <p><strong>Expected</strong>: <code>[string]</code><br>
  <strong>Actual</strong>: <code>[&lt;Invoke&gt;d__40]</code></p>
  <p>$PSVersionTable:</p>
  <pre><code>Name                           Value
  ----                           -----
  PSVersion                      5.1.19041.1237
  PSEdition                      Desktop
  PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
  BuildVersion                   10.0.19041.1237
  CLRVersion                     4.0.30319.42000
  WSManStackVersion              3.0
  PSRemotingProtocolVersion      2.3
  SerializationVersion           1.1.0.1
  </code></pre>
  <p><code>Get-Member -InputObject $invoke</code> reveals this to implement <a href="https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerator?view=netframework-4.8" rel="nofollow noreferrer">IEnumerator</a> and some playing with <code>.MoveNext()</code> and <code>.Current</code> will sometimes output the expected <code>&quot;Hello Person!&quot;</code> result.</p>
  <p>What is this <code>&lt;Invoke&gt;d__40</code> type?<br>
  Why is <code>$command.Invoke()</code> not returning the expected string output directly?</p>