WQL/SCCM - Comparing version numbers correctly (less than...) - sccm

I'm having a problem with this part of a SCCM WQL query looking for "less than version 75.0.3770.80":
... where SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "75.0.3770.80"
If i'm not mistaken this is the good old problem seen before in other scenarios (file names for example) where it will return objects with version number :
75.0.3770.142
Because in it's logic "of course" .142 is "less than" .80 because .1 is less than .8. It doesn't treat it as "142 versus 80" but "1 versus 8"
Is there any way I can work around this? I'm getting a lot of false positives with this query and need to filter them out. If it was straight Powershell I could cast it as [version] but in SCCM, is it at all possible to do this comparison?

If only the last part of the version number is different, we could use the following one.
... where SMS_G_System_ADD_REMOVE_PROGRAMS.Version like "75.0.3770.[1-7][0-9]"
or ... like "75.0.3770.[0-9]"
Best Regards,
Ray

Ended up using SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "75.0.3770"

This goes wrongs if the first version nr reach 100.
Better something like this
SMS_G_System_ADD_REMOVE_PROGRAMS.Version like "75.0.%" and
SMS_G_System_ADD_REMOVE_PROGRAMS.Version < "75.0.3770

Related

DMQL2 Query Syntax for PHRets v2 Seach() to include filter arguments?

(It's been a while since I've been here.)
I've been using the first version of PHRets v1 for years, and understood it well enough to get by, but now I'm trying to understand the advantages of v2.6.2. I've got it all installed and the basics are working fine. My issues are pretty much with comprehending fine points of query syntax that goes into the rets=>Search() statement. (I'm much more familiar with SQL statements). Specifically, I'd like to have a query return a list of properties, EXCLUDING those which already have the status of "Sold".
Here's where I am stuck: If I start with this
`$results = $rets->Search('Property', 'A','*',['Select' => 'LIST_8,LIST_105,LIST_15,LIST_19,listing_office_shortid']);`
That works well enough. BUT I'd like to fit in a filter like:
"LIST_15 != Sold", or "NOT LIST_15=Sold"...something like that. I don't get how to fit/type that into a PHRets Search().
I like PHRets but it is so hard to find well-organized/complete documentation about specific things like this. Thanks in advance.
As in my comment above I've figured out that the filter goes in the third argument position ('*', as in the original question). The tricky thing was having to find a specific "sold" code for each class of properties and placing it in that position like so: '(LIST_15=~B4ZIT1Y75TZ)', (notice the =~ combination of characters that means "does not equal" in this context). I've found the code strings for each of the property types (not clear WHY they would need to be unique for each type of property: "Sold" is Sold for any type, after all) but the correct code for a single-family residential property (type 'A' ...at least for the MLS in which I have to search is:
$results = $rets->Search('Property', 'A','(LIST_15=~B4ZIT1Y75TZ)',['Select' => 'LIST_8,LIST_105,LIST_15,LIST_19,listing_office_shortid']);
(again, the code to go with LIST_15 will be different for the different types of properties.) I think there is a better answer that involves more naturalistic language, but this works and I guess I will have to be satisfied with it for now. I hope this is of some use to anyone else struggling with this stuff.

Mockaroo Formulas for random date range using Ruby

I am trying to create a data field using Mockaroo and they say they have Ruby support but I know nothing about Ruby so I am trying to find out how to do a field that will randomly choose between the 3 options.
now() or
now()+days(-1) or
now()+days(-2) or
now()+days(-3)
Idea 1
I was initially thinking something using random like now()+days(this.rand(-3))
Idea 2
I also thought of using or logic like now() or now()+days(-3) or etc...
This answer may end up being different than a typical ruby solution since Mockaroo has their own little API to use too... Appreciate any help that can be given.
Turns out I had to use the random function first and pass in min and max date parameters.
random(now()+days(2), now()+days(-3))

Convert string with comma to integer

Is there any neat method to convert "1,112" to integer 1112, instead of 1?
I've got one, but not neat:
"1,112".split(',').join.to_i #=> 1112
How about this?
"1,112".delete(',').to_i
You may also want to make sure that your code localizes correctly, or make sure the users are used to the "international" notation. For example, "1,112" actually means different numbers across different countries. In Germany it means the number a little over one, instead of one thousand and something.
Corresponding Wikipedia article is at http://en.wikipedia.org/wiki/Decimal_mark. It seems to be poorly written at this time though. For example as a Chinese I'm not sure where does these description about thousand separator in China come from.
Some more convenient
"1,1200.00".gsub(/[^0-9]/,'')
it makes "1 200 200" work properly aswell
The following is another method that will work, although as with some of the other methods it will strip decimal places.
a = 1,112
b = a.scan(/\d+/).join().to_i => 1112
I would do using String#tr :
"1,112".tr(',','').to_i # => 1112
If someone is looking to sub out more than a comma I'm a fan of:
"1,200".chars.grep(/\d/).join.to_i
dunno about performance but, it is more flexible than a gsub, ie:
"1-200".chars.grep(/\d/).join.to_i
String count = count.replace(",", "");

Ruby regular expression for asterisks/underscore to strong/em?

As part of a chat app I'm writing, I need to use regular expressions to match asterisks and underscores in chat messages and turn them into <strong> and <em> tags. Since I'm terrible with regex, I'm really stuck here. Ideally, we would have it set up such that:
One to three words, but not more, can be marked for strong/em.
Patterns such as "un*believ*able" would be matched.
Only one or the other (strong OR em) work within one line.
The above parameters are in order of importance, with only #1 being utterly necessary - the others are just prettiness. The closest I came to anything that worked was:
text = text.sub(/\*([(0-9a-zA-Z).*])\*/,'<b>\1<\/b>')
text = text.sub(/_([(0-9a-zA-Z).*])_/,'<i>\1<\/i>')
But it obviously doesn't work with any of our params.
It's odd that there's not an example of something similar already out there, given the popularity of using asterisks for bold and whatnot. If there is, I couldn't find it outside of plugins/gems (which won't work for this instance, as I really only need it in in one place in my model). Any help would be appreciated.
This should help you finish what you are doing:
sub(/\*(.*)\*/,'<b>\1</b>')
sub(/_(.*)_/,'<i>\1</i>')
Firstly, your criteria are a little strange, but, okay...
It seems that a possible algorithm for this would be to find the number of matches in a message, count them to see if there are less than 4, and then try to perform one set of substitutions.
strong_regexp = /\*([^\*]*)\*/
em_regexp = /_([^_]*)_/
def process(input)
if input ~= strong_regexp && input.match(strong_regexp).size < 4
input.sub strong_regexp, "<b>\1<\b>"
elsif input ~= em_regexp && intput.match(em_regexp).size < 4
input.sub em_regexp, "<i>\1<\i>"
end
end
Your specifications aren't entirely clear, but if you understand this, you can tweak it yourself.

mod_rewrite numeral ranges

i'm setting up a directory structure based on dates: 2010/02/01
right now, my rewrite rules look something like this:
([0-9]{4})/([0-9]{2})/([0-9]{2})
I tried limiting the ranges - the month, for instance: ([01-12]{2}) - but that doesn't seem to work. is there a way to do this, or am i making this too complicated and i shouldn't worry about it?
i don't want something like: (01|02|03...10|11|12)
thanks!
Regular expressions don't see numbers as numbers. It sees each individual digit as a character. So, [01-12] would actually equivocate to [012] or [0-2]. (Someone correct me if I'm wrong on that.)
I'm not a master at RexEx, so someone might have a better solution, but here's what I'd use:
(2\d{3})/(1[0-2]|0[1-9])/(3[0-1]|[1-2]\d|0[1-9])
Untested, but that should restrict your year to the 2000s, your months to 01-12, and your days to 01-31.

Resources