Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Find the Largest Number in a PowerShell Array

$
0
0

Summary: Easily find the largest number in a Windows PowerShell array.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily find the largest number in an array of numbers?

Hey, Scripting Guy! Answer Pipe the array to the Measure-Object cmdlet, and use the –Maximum switch:

PS C:\> $a = [array]1,2,5,6,3,2,9,1

PS C:\> $a | measure -Maximum

 

Count    : 8

Average  :

Sum      :

Maximum  : 9

Minimum  :

Property :


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>