# query computer name by AD account

**URL:** <https://forums.powershell.org/t/query-computer-name-by-ad-account/9183>\
**Category:** PowerShell Help\
**Created:** [August 16, 2017, 4:36am UTC](https://forums.powershell.org/t/query-computer-name-by-ad-account/9183 "2017-08-16T04:36:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marka01](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@marka01](https://forums.powershell.org/u/marka01)\
**Post date:** [August 16, 2017, 4:36am UTC](https://forums.powershell.org/t/query-computer-name-by-ad-account/9183/1 "2017-08-16T04:36:54Z")

</div>

Is there a way to query/check what was the computer name to which a particular AD account was last logged on?

---

<div class="post-metadata">

**Author:** ![simbrook](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@simbrook](https://forums.powershell.org/u/simbrook)\
**Post date:** [August 16, 2017, 5:37am UTC](https://forums.powershell.org/t/query-computer-name-by-ad-account/9183/2 "2017-08-16T05:37:05Z")

</div>

Do you use SCCM in your environment ? If so this may provide an audit of where the user logged in.

> **[SCCM 2012: Query to find clients a user last logged in to](https://configmonkey.wordpress.com/2015/04/29/sccm-2012-query-to-find-clients-a-user-last-logged-in-to/)**
>
> Summary: Using SCCM to query the ConfigMgr database to find which clients a particular user had logged in to. Issue: A customer wanted to know a history of which clients on their estate a particula…

with that list to see the current logged in user run this

Get-CimInstance –ComputerName CLIENT1 –ClassName Win32\_ComputerSystem | Select-Object UserName

Or you can crawl the security logs on you DC’s

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [August 16, 2017, 6:00am UTC](https://forums.powershell.org/t/query-computer-name-by-ad-account/9183/3 "2017-08-16T06:00:07Z")

</div>

Please follow the How-to article for step-wise instructions - [How to track user logon sessions using event log - Active Directory & GPO - Spiceworks](https://community.spiceworks.com/how_to/130398-how-to-track-user-logon-sessions-using-event-log)

---

<div class="post-metadata">

**Author:** ![simbrook](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@simbrook](https://forums.powershell.org/u/simbrook)\
**Post date:** [August 16, 2017, 6:03am UTC](https://forums.powershell.org/t/query-computer-name-by-ad-account/9183/4 "2017-08-16T06:03:56Z")

</div>

This may also help [Solved: PowerShell Script to get Last Logon of User | Experts Exchange](https://www.experts-exchange.com/questions/28501625/PowerShell-Script-to-get-Last-Logon-of-User.html)

The other option apart from above is to use logon scripts and write to a hidden share somewhere the computer name, username, logon time etc

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:37pm UTC](https://forums.powershell.org/t/query-computer-name-by-ad-account/9183/5 "2024-05-16T20:37:45Z")

</div>


