Function Compare-VersionNumber { param( [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [AllowEmptyString()] [alias("Version1")] [string] $ver1, [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 1)] [AllowEmptyString()] [alias("Version2")] [string] $ver2 ) If($ver1 -eq '' -or $ver1 -eq $null) { $ver1 = '0' } if($ver2 -eq '' -or $ver2 -eq $null) { $ver2 = '0' } # 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 = "Less"; $i = $count + 1 } 0 { $compare = "Equal" } 1 { $compare = "Greater"; $i = $count + 1 } } } return $compare } #region issue here $TemplateCollections = @() $TemplateCollections += New-Object PSObject -Property @{ColNb = "00" Name ="Clients | All" Query= "select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.Client = 1" LimitingCollection = $LimitingCollection Comment = "All devices detected by SCCM"} #endregion