Is it possible to use -Like with ADSI query? - adsi

Sometimes my AD queries using the ADSI method fails on surnames with Jr. or III on the end of the name. Is it possible with ADSI to capture the last names using the -LIKE filter?
For example:
$search = [adsisearcher]"(&(objectCategory=person)(objectClass=User)(sn -like Perry))"

Related

Odata query $filter alternative

Are there any alternatives to $filter in OData query options ?
Below is my $filter code to select certain data from SharePoint. But due to certain problems with the server, I was unable to execute the query. Are there any alternatives such as $select statement or whichever that does the same function as below ?
ListData?$filter=ContentType eq 'Item'&$top=100
$filter is the only option for filtering data, there is no other way to get only ListData where the ContentType is Item. Alternatively, (and much less performantly), if you really can't do $filter but need to get the data, you could just get back all of the data and do the filtering on the client.

Get a single, matching row from a .csv without searching twice?

I was wondering if there was a better way I can grab a single row matching a specific query, without searching twice.
In my code originally, I wanted to count how many rows in my .CSV matched my search query.
$raisins=($table | ? {$_.'fruit' -like '*grapes*' -and $_.'hours in sunlight' -like '*a lot*'}| measure).Count
Now, I'm tasked with taking a single row from those same search query results.
$raisinHit=($table | ? {$_.'fruit' -like '*grapes*' -and $_.'hours in sunlight' -like '*a lot*})
$raisinHit=$raisinHit[0]
However, I find it really inefficient that I have to search through my .CSV using the same query from earlier, just to find a single result I had already glossed over.
Is there a better way to do this? If so, can you explain how?
Just assign the matches to a variable, then return the count and an element from the variable.
$raisins = #($table |
? {$_.'fruit' -like '*grapes*' -and $_.'hours in sunlight' -like '*a lot*'})
$raisins.count
$raisins[0]
The #() around the pipeline ensures that $raisins will be an array, even if only one match is returned.

IN operator in WQL

I need to write a WMI query where I need to check that some value is equal to one of the values in the list, but I didn't find that WQL supports IN operator like SQL.
For example:
SELECT * FROM Device WHERE __CLASS IN ("Device1", "Device20").
What are the ways how to write this query?
Thanks.
The WMI uses the WQL language which is only a subset of the SQL language, and doesn't include the IN operator.
So you can rewrote tor sentence using the OR operator , like so
SELECT * FROM Win32_LogicalDisk Where (DriveType=3) or (DriveType=5)
or using the your WQL sentence.
SELECT * FROM Device WHERE (__CLASS="Device1") OR (__CLASS="Device20")

Linq OData "Where" clause on nested list

Say I have the following query OData Linq Query (run against http://odata.netflix.com/v2/Catalog):
Genres.Where(x=>x.Name=="Adventures")
.Select(y=> new
{
Genre = y.Name,
Movie = y.Titles.Select(l=> new
{
l.Name,
l.AverageRating
})
})
How could I change this query to give me the rows where AverageRating was 3?
(NOTE: The point of this question is to find out how to do a where clause on properties of an expanded sub list of my main level query item. My real query is not even against the Netflix OData feed.)
The short answer is that it's not possible currently.
The $filter always (and only) applies to the top-level entity set. There's currently no way to filter expanded entity sets.
The $filter can reach inside the expanded entity sets but the result will always filter the top-level set. In V2 it works for singleton navigation properties (the expression in $filter can traverse those), in V3 you can use the any/all to also incorporate collection navigation properties.
The reason this can't work is that the OData protocol doesn't define the URI syntax for nested filters. In fact it doesn't define almost any operator on the expanded entity sets except for the expansion itself and projections.

Solr OR query for different combination of facets

I have a sample Solr schema as follows
isPublic = boolean
source = facebook| twitter | wordpress
I want to write a query which returns all documents from the index which matches either the isPublic = true or isPublic is false and source= facebook. Something like this
solrUrl/?q=blah&fq=(isPublic:true OR (isPublic:false AND source:facebook))
Is such a thing possible or should I search the index two times with each of these conditions and then combine + de-duplicate the results?
Sure you can run such a filter query, but I think that particular query will not get you the results you're looking for, see this question about it. A logically equivalent query would be: isPublic:true OR source:facebook

Resources