# Get a the list of logged in users from Windows AD and alert when there is a new one.

**URL:** <https://community.dynatrace.com/t/get-a-the-list-of-logged-in-users-from-windows-ad-and-alert-when-there-is-a-new-one/49912>\
**Category:** Alerting\
**Tags:** davis, anomaly-detection, problems\
**Created:** [January 24, 2025, 4:12pm UTC](https://community.dynatrace.com/t/get-a-the-list-of-logged-in-users-from-windows-ad-and-alert-when-there-is-a-new-one/49912 "2025-01-24T16:12:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryan\_araya](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@bryan\_araya](https://community.dynatrace.com/u/bryan_araya)\
**Post date:** [January 24, 2025, 4:12pm UTC](https://community.dynatrace.com/t/get-a-the-list-of-logged-in-users-from-windows-ad-and-alert-when-there-is-a-new-one/49912/1 "2025-01-24T16:12:16Z")

</div>

Hello

I need to know what ways exist to be able to get the list of logged in users on Windows host to create an alert when a new user log in the host.

I know, you can get a list of users in Windows using PowerShell, but no matter how much I look, I don’t know if you can have a PowerShell extension to be able to inject the results into Dynatrace or is there another way to do it, for example using Windows logs.

Regards Bryan

---

<div class="post-metadata">

**Author:** ![Maheedhar\_T](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maheedhar_t/32/155_2.png) [@Maheedhar\_T](https://community.dynatrace.com/u/Maheedhar_T)\
**Post date:** [January 27, 2025, 5:33am UTC](https://community.dynatrace.com/t/get-a-the-list-of-logged-in-users-from-windows-ad-and-alert-when-there-is-a-new-one/49912/2 "2025-01-27T05:33:42Z")

</div>

[@bryan\_araya](https://community.dynatrace.com/user/38300)&nbsp;,  
I’m suggesting this solution from whatever limited knowledge I have, you can ingest the log file&nbsp; **C:\Windows\System32\winevt\Logs\Security.evtx** &nbsp;to Dynatrace. Then using DQL you can filter out the standard users and say when a user apart from these set of users log-in create an alert.  
Hope this helps.

---

<div class="post-metadata">

**Author:** ![bryan\_araya](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@bryan\_araya](https://community.dynatrace.com/u/bryan_araya)\
**Post date:** [January 27, 2025, 9:07pm UTC](https://community.dynatrace.com/t/get-a-the-list-of-logged-in-users-from-windows-ad-and-alert-when-there-is-a-new-one/49912/3 "2025-01-27T21:07:04Z")

</div>

Hi

Actually what I need is something more complex but I wanted to start with something simple.

I know that you can do something similar with the Windows logs but what i need is the list of users of a host to compare it with the new users to see if any are new or have been modified users. This open an alert in Dynatrace if there is a change to the original list of users.

---

<div class="post-metadata">

**Author:** ![RohitBisht](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rohitbisht/32/38577_2.png) [@RohitBisht](https://community.dynatrace.com/u/RohitBisht)\
**Post date:** [January 28, 2025, 12:59am UTC](https://community.dynatrace.com/t/get-a-the-list-of-logged-in-users-from-windows-ad-and-alert-when-there-is-a-new-one/49912/4 "2025-01-28T00:59:13Z")

</div>

This can be done as a 2-step process.  
1. Ingest the logs -&nbsp;[Solved: Custom Log Source - Windows Event Log - Dynatrace Community](https://community.dynatrace.com/topic/208782)  
2. Compare it with approved set of users list.  
&nbsp; &nbsp; &nbsp; &nbsp;- If logs are on Grail, you can ingest the list as a log entry and then compare it using DQL. OR dynamically you can create the user dataset using this&nbsp;[DQL data source commands — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/data-source-commands#data)&nbsp;and then compare it.

- If you don’t have Grail yet or work in Dynatrace managed, you can use log processing rule’s function FIELDS\_ADD to compare, a sample below. You can use multiple such lines, but this is difficult to scale for a big list of users.

USING(INOUT username:STRING, content)

| FIELDS\_ADD(UnknownUser: IF(username != ‘XYZ’,"NOT FOUND’'))

---

<div class="post-metadata">

**Author:** ![Maheedhar\_T](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maheedhar_t/32/155_2.png) [@Maheedhar\_T](https://community.dynatrace.com/u/Maheedhar_T)\
**Post date:** [January 28, 2025, 6:23am UTC](https://community.dynatrace.com/t/get-a-the-list-of-logged-in-users-from-windows-ad-and-alert-when-there-is-a-new-one/49912/5 "2025-01-28T06:23:04Z")

</div>

Instead of needing to make a dataset of current users, we can use DQL to check the number of Unique users at this point, create a metric of it using log enrichment and metric extraction.  
Then whenever there’s an increase on that number, we can create a metric event. That way we’d know someone new have logged in.
