Author Posts

February 2, 2018 at 8:27 pm

Can someone please help me understand this

@("taco").gettype()
This outputs the type that I would expect

(&{@("taco")}).gettype()
In a scriptblock it outputs a string. Same thing for a function obviously.

Any help will be appreciated.

February 2, 2018 at 8:29 pm

In the latter case you're forcing the shell to evaluate the array and enumerate its contents. Given that it has one item, which is a string, that's what you get. That's standard .NET behavior, not really PowerShell per se.

February 2, 2018 at 9:02 pm

Thanks Don. That makes sense.