# Metric for knowing if a Win server has remote logged in users?

**URL:** <https://community.dynatrace.com/t/metric-for-knowing-if-a-win-server-has-remote-logged-in-users/43360>\
**Category:** Extensions\
**Tags:** wmi, extensions\
**Created:** [December 26, 2023, 12:16am UTC](https://community.dynatrace.com/t/metric-for-knowing-if-a-win-server-has-remote-logged-in-users/43360 "2023-12-26T00:16:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntonioSousa](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antoniosousa/32/50_2.png) [@AntonioSousa](https://community.dynatrace.com/u/AntonioSousa)\
**Post date:** [December 26, 2023, 12:16am UTC](https://community.dynatrace.com/t/metric-for-knowing-if-a-win-server-has-remote-logged-in-users/43360/1 "2023-12-26T00:16:21Z")

</div>

I’m trying to establish a metric of the number of remote logged in users in Windows servers.

I’m trying to do it through WMI, but still working on how to do it…

Has anyone managed to do this?

---

<div class="post-metadata">

**Author:** ![AntonioSousa](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antoniosousa/32/50_2.png) [@AntonioSousa](https://community.dynatrace.com/u/AntonioSousa)\
**Post date:** [December 29, 2023, 11:46am UTC](https://community.dynatrace.com/t/metric-for-knowing-if-a-win-server-has-remote-logged-in-users/43360/2 "2023-12-29T11:46:37Z")

</div>

Just to give Feedback on how I managed to do it. Used query below to grab number of active sessions in Terminal Services, and then coded a v2 extension:

```markup
$computerName = "192.168.111.20"
$credential = Get-Credential 
Get-WmiObject -Class Win32_PerfFormattedData_LocalSessionManager_TerminalServices -ComputerName $computerName -Credential $credential | Select-Object -ExpandProperty ActiveSessions

```
