From 1a6feee86ef97b4634a360492ec0dfe297ca0fd5 Mon Sep 17 00:00:00 2001 From: Gabe Date: Tue, 5 Aug 2025 02:48:15 +0000 Subject: [PATCH] Upload files to "Functions Scripts" --- .../function to compare version numbers.ps1 | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Functions Scripts/function to compare version numbers.ps1 diff --git a/Functions Scripts/function to compare version numbers.ps1 b/Functions Scripts/function to compare version numbers.ps1 new file mode 100644 index 0000000..2b75f99 --- /dev/null +++ b/Functions Scripts/function to compare version numbers.ps1 @@ -0,0 +1,28 @@ +$ver1 = "115.0.5790.99" +$ver2 = "115.0.5790.171" + +Function verCompare($ver1, $ver2) { + # returns whether ver1 is Less, Greater, or Equal to ver2 + $ver1Array = $ver1.Split(".") + $ver2Array = $ver2.Split(".") + + # Decide which array has the least amount of subversions and we'll only compare the least amount + If ($ver1Array.count -ge $ver2Array.count) { $count = $ver1Array.count } + Else { $count = $ver2Array.count } + + # Loop through each sub version and compare them. + # Once I hit a Greater or Less than I change the count to break + # Out of the for loop because there is no need to compare further + For ($i = 0; $i -lt $count; $i++) { + Switch ( $ver1Array[$i].CompareTo($ver2Array[$i]) ) { + -1 { $compare = "$ver1 Less than $ver2"; $i = $count + 1 } + 0 { $compare = "$ver1 Equal to $ver2" } + 1 { $compare = "$ver1 Greater than $ver2"; $i = $count + 1 } + } + } + + return $compare + +} + +verCompare $ver1 $ver2 \ No newline at end of file