Michael Klement

Results 1234 comments of Michael Klement

> Can we detect if piping is used from `$input`? Use `$MyInvocation.ExpectingInput` ```powershell & { $MyInvocation.ExpectingInput } # -> $false 1 | & { $MyInvocation.ExpectingInput } # -> $true ```...

I answered your questions in isolation, You need to combine your logic with `$MyInvocation.ExpectingInput` as needed, to distinguish the pipeline from the non-pipeline scenarios. Apart from that, I see no...

With respect to backtick-escaping (`` ` ``): * Only ever _one_ `` ` `` should be required to escape `[` and `]` - irrespective of whether `-Recurse` is present or...

A `-Strict` mode sounds like a useful addition, to not just check for extraneous trailing commas, but also for the presence of `// ... ` comments, which are also accepted...

Thanks for the detailed analysis, @SeeminglyScience. If removing runspace affinity is too risky, perhaps another option is to simply _recreate_ classes in the target runspace, similar to what is already...

While disallowing cross-thread class use is definitely the safest option, it also takes away potentially useful functionality. Given the "less solid" nature of PowerShell classes my guess is that loss...

Thanks, @PetSerAl. I can see how with _nested_ collections the behavior differs: ```powershell > Format-List -InputObject 1, (2, (3, 4)) 1 Length : 2 LongLength : 2 Rank : 1...

Good tip, @vexx32. Were you thinking along the following lines? ```powershell function foo { [CmdletBinding()] param( [Parameter(ValueFromPipeline)] [object] $Param1 # declare as scalar ) process { if ($MyInvocation.ExpectingInput) { #...

Cool, thanks. Can we conclude that the best way to implement an item-by-item processing cmdlet that also supports collections as arguments via `-InputObject` is to use the above approach, based...