Save this script as a .ps1 file and edit the username in the last line of the script (in bold below), then run it. On the AD computer object you can goto attribute editor tab (in modern versions of AD tools) and look for lastLogonTimeStamp which will tell you when the computer last booted or logged into the network (every computer on the Domain actually logs in with their own secret password). If possible, I want it from AD objects instead of running a script at user … Active 3 years, 5 months ago. In Powershell, run this command to get the data you need, then scroll down the list and look for LastLogonDate. You can find last logon date and even user login history with the Windows event log and a little PowerShell! If you want to retrieve all logged on users of all computers in this OU run Get-UserLogon -OU 'ou=Workstations,dc=sid-500,dc=com' The second example shows the current logged on user on all Domain Controllers. Normally, you can just fire up Get-WmiObject with calling Win32_ComputerSystem class to get the info. I am looking for a script to get computer last logged in time, computer name, device type and office version used by all users in an OU. I was wondering if there was a way in Active Directory to query a Computer object to find the last user who logged on. The code below gets the currently logged on user from windows explorer. In ADUnC, make sure Advanced is selected from under view menu.


Find answers to Powershell script needed: query computer for last logged in user and look user up on AD from the expert community at Experts Exchange

2. PowerShell: Get-ADComputer to retrieve computer last logon date – part 1. I have a problem in that I need to detect when a user is logged on to a system so that I can patch it and reboot the machine without disrupting the individual. Viewed 157k times 6. I'm trying to get a script together that will ping a list of computers to see if they're on, then query them and tell me who is logged into each computer and output it to a .csv file.

Leave it in the comments of the YouTube video. This script will pull information from the Windows event log for a local computer and provide a detailed report on user login activity. Here is how to get the login on a local computer. Option 2 – This snippet uses the win32_process WMI class to get the username of any user that has an Explorer process open. The next method is to use the Powershell script below. I’ve written about Get-ADUser several times already to find out Active Directory user information, but in this post we’ll be using Get-ADComputer to find out the last logon date for the computers in Active Directory. If you have some other method using PowerShell, I would love to hear about it.