如何防止 PowerShell 的 Measure-Object cmdlet 截断您的数据? [英] How to prevent PowerShell's Measure-Object cmdlet from truncating your data?
问题描述
我正在尝试比较以下数据以获得最大数字:
I am tryng to compare the following data to obtain the largest number:
$UserDeets
name lastLogon
---- ---------
Frank Ti 132273694413991065
Frank Ti 132279742884182029
Frank Ti 132282196073500496
Frank Ti 132272912975826719
Frank Ti 132282144707771693
Frank Ti 132228790551703041
为此,我尝试使用内置的测量"功能.这是我正在执行的代码
To do this I am trying to use the built in 'measure' function. This is the code I am executing
($UserDeets| measure -Property lastLogon -Maximum ).Maximum
结果如下
1.322821960735E+17
正如您所看到的,它返回了正确的数据,但它正在截断最后几位数字.
As you can see althogh it is returning the correct data it is truncating the last few digits off.
有没有办法防止这种截断?
Is there a way to prevent this truncation?
推荐答案
好的,我有一个解决方案.答案是不要使用度量".这是一个变通方法,但它得到了想要的答案.
OK I have a solution to this. The answer is to not use 'measure'. This is a work around, but it gets the desired answer.
首先我对数组进行排序:
First i sorted the array:
$UserDeets = ($UserDeets | Sort-Object -Property LastLogon)
最高的对象将在数组的末尾,可以这样获得:
the highest object will be at the end of the array and can be obtained like this:
$UserDeets[-1]
这篇关于如何防止 PowerShell 的 Measure-Object cmdlet 截断您的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!