@Kayasax's answer will give you the string(value) for the longest string. The reason your code didn't work was because you measured the items in the array, not the length. For that, you need to specify the -Property Length
parameter in Measure-Object
, like this:
PS> ("lalala","hehe","hi" | Measure-Object -Maximum -Property Length).Maximum
6