# Powershell query examples

**URL:** <https://discuss.elastic.co/t/powershell-query-examples/201439>\
**Category:** Elasticsearch\
**Created:** [September 27, 2019, 4:49pm UTC](https://discuss.elastic.co/t/powershell-query-examples/201439 "2019-09-27T16:49:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [September 27, 2019, 4:49pm UTC](https://discuss.elastic.co/t/powershell-query-examples/201439/1 "2019-09-27T16:49:56Z")

</div>

I do my scripting in python, usually using the elaticsearch-dsl. I want to convert a simple query to Powershell to share with some non-python users.

If I could find a simple query that uses the scroll API, I could use it as a starting point, but all the examples I find seem to be unduly complicated.

Here's the central logic of my python:

```
s = Search(using=es, index = 'winlogbeat-*') \
        .query("match", source_name="MSExchange CmdletLogs") \
        .query("exists", field="event_data.param12") \
        .filter("range", ** {'@timestamp': {'gte': 'now-24h/m', 'lt': 'now/m'}})

for hit in s.scan(): 
    if "needle" in hit["event_data"]["param12"]:
    ....

```

Basically, I need to do a text search on the param12 field but it's stored as a keyword. I can shrink the sample down to a few 1000 events in the elasticsearch query and text scan those results quickly.

So, I just need a simple example to start with 🙂  
Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 25, 2019, 5:02pm UTC](https://discuss.elastic.co/t/powershell-query-examples/201439/2 "2019-10-25T17:02:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
