# Winlogbeat Powershell Module

**URL:** <https://discuss.elastic.co/t/winlogbeat-powershell-module/347019>\
**Category:** Beats\
**Tags:** winlogbeat\
**Created:** [November 13, 2023, 1:35pm UTC](https://discuss.elastic.co/t/winlogbeat-powershell-module/347019 "2023-11-13T13:35:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fsch](https://avatars.discourse-cdn.com/v4/letter/f/7ba0ec/32.png) [@fsch](https://discuss.elastic.co/u/fsch)\
**Post date:** [November 13, 2023, 1:35pm UTC](https://discuss.elastic.co/t/winlogbeat-powershell-module/347019/1 "2023-11-13T13:35:31Z")

</div>

Hi everyone  
we try to ship Powershell logs (Event ID: 4103 / Provider: Microsoft-Windows-PowerShell) to elastic.  
Using the field "powershell.command.name" in our .yml file ( [PowerShell module fields | Winlogbeat Reference [7.17] | Elastic](https://www.elastic.co/guide/en/beats/winlogbeat/7.17/exported-fields-powershell.html) the filtering on commandlet names works fine.

But using the JSON objects within the invocation\_details array doesn't.  
I try to filter on Get-WMI cmdlet events using certain wmi-classes (field powershell.command.invocation\_details.value) or using the field powershell.command.invocation\_details.related\_command  
but I can't get it working using any of the powershell.command.invocation\_details - fields from the documentation above.  
I assume there is something wrong in my way to address those json object properties ("value" / "related\_command") within the invocation\_destails array, but I can't figure out what.

As for a simple rule I tried:

```auto
processors:
  - script:
	  lang: javascript
	  id: powershell-operational
	  file: "C:/Program Files/winlogbeat/module/powershell/config/winlogbeat-powershell.js"
  - drop_event.when.not:
	  or:
		- equals.powershell.command.invocation_details.related_command: 'Get-WmiObject'
		- contains.powershell.command.invocation_details.related_command: 'Get-WmiObject'

```

but none of the events are written to the path. in output.file  
As I wrote - equals.powershell.command.name: 'Clear-EventLog' is working fine.

Output (when redirecting to file) using no filter looks like this:

```auto
"powershell": {
        "command": {
            "name": "Get-WmiObject",
            "type": "Cmdlet",
            "invocation_details": [{
                    "type": "CommandInvocation",
                    "related_command": "Get-WmiObject",
                    "value": "\"Get-WmiObject\""
                }, {
                    "name": "\"Class\"",
                    "value": "\"Win32_OperatingSystem\"",
                    "type": "ParameterBinding",
                    "related_command": "Get-WmiObject"
                }, {
                    "type": "CommandInvocation",
                    "related_command": "Out-Default",
                    "value": "\"Out-Default\""
                }, {
                    "value": "\\\\\MCOSRV2061\\root\\cimv2:Win32_OperatingSystem=@\",
                    "type": "ParameterBinding",
                    "related_command": "Out-Default",
                    "name": "\"InputObject\""
                }
            ]
        }
}

```

Does anybody have a clue what's the correct way to address the values of the properties "related\_command" and "value" within the "invocation\_details"?

Thanks a lot in advance for any input.

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [November 20, 2023, 5:07pm UTC](https://discuss.elastic.co/t/winlogbeat-powershell-module/347019/2 "2023-11-20T17:07:37Z")

</div>

AFAIK beats processors don't work with arrays. But you could do this type of event filtering using the script processor and calling the `Cancel()` function if you find commands that you want to ignore.

> **[Script Processor | Winlogbeat Reference \[7.17\] | Elastic](https://www.elastic.co/guide/en/beats/winlogbeat/7.17/processor-script.html#_event_api)**

---

<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:** [December 18, 2023, 7:08pm UTC](https://discuss.elastic.co/t/winlogbeat-powershell-module/347019/3 "2023-12-18T19:08:02Z")

</div>

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