Saturday, May 11, 2019

Powershell: [System.Version]$_

Use version class for comparing dotted numbers, such as IP address.

PS C:\Users\drago> $IPAddresses = @(
>> '10.10.12.13',
>> '10.11.102.3',
>> '10.12.10.26',
>> '10.13.10.252'
>> );


PS C:\Users\drago> $IPAddresses | Sort { [System.Version]$_ }

10.10.12.13
10.11.102.3
10.12.10.26
10.13.10.252


#powershell, #dotnetframework, #windows

No comments:

Post a Comment