How to get all User Name with Machine Name, etc. logged on Network
We are running an enviornment of Windows Server R2 2008 with Windows 7 Client and some windows XP client which we will be upgrading to windows 7, all client are upgraded via SCCM 2007, is there is a way to pull up a list via command line or some other way to get all username logged in or last logged in with their Machine name, if possible as well as Mac Address, ip Address etc.
May 19th, 2011 12:44pm

The best solution I know of is a logon script that logs user name, computer name, and date/time to a shared log file. I have an example linked here: http://www.rlmueller.net/Logon5.htm The Logon5.vbs linked on the page also logs the current IP address. With the newer OS's like you have, this code could be replaced with code that uses WMI. You could also add code using WMI to retrieve the MAC address. The following example shows how to retrieve both the IP address and MAC address of the local computer using the Win32_NetworkAdapterConfiguration class of WMI: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration") On Error Resume Next For Each objItem in colItems Wscript.Echo "IP Address: " & objItem.IPAddress Wscript.Echo "MAC Address: " & objItem.MACAddress Next Richard Mueller - MVP Directory Services
Free Windows Admin Tool Kit Click here and download it now
May 19th, 2011 1:17pm

Ok but will it not keep adding to log file every day user log in or out, and at some point if we need a current/latest report/list, we have to pull up the log and pick from there. Our main objective is if we want to pull up the current/latest list of our machine name associated to username and if possible mac address not important, FYI we don't use roming profile. is there a command on network or any free utility.
May 19th, 2011 4:08pm

AD does not keep track of which computer a user logs into. I don't recall even seeing a way to take a snapshot of which computer each user is logged into at the moment. You would need a solution that uses logon and logoff scripts and maintains a separate database. LimitLogin is the best known: http://technet.microsoft.com/en-us/magazine/2005.05.utilityspotlight.aspx While the purpose of LimitLogin is to restrict the number of concurrent logons, it can also be used just to track logons (I assume it tracks which computer is used by each user). Richard Mueller - MVP Directory Services
Free Windows Admin Tool Kit Click here and download it now
May 19th, 2011 5:22pm

won't your SCCM environment have all that data? Top users for all Systems for example (from the sccm reporting server). You may need to write a custom report if you want Maxc addresses / ip addresses added to the report. > Our main objective is if we want to pull up the current/latest list of our machine name associated to username SCCM reporting, report "Computers for a specific user name" will cover that
May 19th, 2011 6:32pm

not sure how to get it on SCCM as we just inducted SCCM in our enviornment, Can you please help, where or how to get/pull the report in SCCM
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2011 2:58pm

I find it, but it will report of each user, so I have to pull report for every user for get the computer name, but if we want the list of all username with machine name, how to get that.
May 24th, 2011 3:25pm

Hi, you can create a report in SCCM using below query or you can run the same in SCCM SQL box - SELECT distinct sys.Netbios_Name0 ComputerName, sys.user_name0,ipsub.IP_Subnets0, ip.defaultIPGateway0, sys.AD_site_name0 ADSite from v_R_system sys inner join v_GS_Network_Adapter_Configur IP on sys.ResourceID=IP.ResourceID inner join v_RA_System_IPSubnets ipsub on sys.ResourceID=ipsub.ResourceID where sys.resource_domain_or_workgr0 = 'DomainName' and sys.obsolete0=0 and ip.defaultIPGateway0 is not NULL and ipsub.IP_Subnets0 is not NULL; Hope it helps you.Rakesh Kumar
Free Windows Admin Tool Kit Click here and download it now
September 16th, 2011 1:21pm

this is only for one person. where can get a list for all users with sccm?
June 6th, 2012 7:21pm

the above SQL query can be used for getting the reports for all user and systems which reports to SCCM. If you want you can add IP address and MAC Address as well. you can use the below logon/logoff script using AD group Policy to get the report with latest staus of users and their systems. Logon.vbs - Option Explicit Dim objFSO, objLogFile, objNetwork, objShell, strText, intAns, strComputer, objWMIService, colChassis, strChassisType,strType, objChassis Dim intConstants, intTimeout, strTitle, intCount, blnLog Dim strUserName, strComputerName, strIP, strShare, strLogFile strShare = "\\servername\Audit-Logon" strLogFile = "login.csv" intTimeout = 20 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objNetwork = CreateObject("Wscript.Network") Set objShell = CreateObject("Wscript.Shell") strUserName = objNetwork.UserName strComputerName = objNetwork.ComputerName strIP = GetIP() ''''''''''''''''''''''''''''''''''''' strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colChassis = objWMIService.ExecQuery _ ("Select * from Win32_SystemEnclosure") For Each objChassis in colChassis For Each strChassisType in objChassis.ChassisTypes Select Case strChassisType Case 1 strType = "Other" Case 2 strType = "Unknown" Case 3 strType = "Desktop" Case 4 strType = "Low Profile Desktop" Case 5 strType = "Pizza Box" Case 6 strType = "Mini Tower" Case 7 strType = "Tower" Case 8 strType = "Portable" Case 9 strType = "Laptop" Case 10 strType = "Notebook" Case 11 strType = "Handheld" Case 12 strType = "Docking Station" Case 13 strType = "All-in-One" Case 14 strType = "Sub-Notebook" Case 15 strType = "Space Saving" Case 16 strType = "Lunch Box" Case 17 strType = "Main System Chassis" Case 18 strType = "Expansion Chassis" Case 19 strType = "Sub-Chassis" Case 20 strType = "Bus Expansion Chassis" Case 21 strType = "Peripheral Chassis" Case 22 strType = "Storage Chassis" Case 23 strType = "Rack Mount Chassis" Case 24 strType = "Sealed-Case PC" Case Else strType = "Unknown" End Select Next Next '''''''''''''''''''''''''''''''''''''''' ' Log date/time, user name, computer name, and IP address, computer Type If (objFSO.FolderExists(strShare) = True) Then On Error Resume Next Set objLogFile = objFSO.OpenTextFile(strShare & "\" _ & strLogFile, 8, True, 0) If (Err.Number = 0) Then ' Make three attempts to write to log file. intCount = 1 blnLog = False Do Until intCount = 3 objLogFile.WriteLine "Logon," & Now & "," _ & strComputerName & "," & strUserName & "," & strIP & "," & strType If (Err.Number = 0) Then intCount = 3 blnLog = True Else Err.Clear intCount = intCount + 1 If (Wscript.Version > 5) Then Wscript.Sleep 200 End If End If Loop On Error GoTo 0 If (blnLog = False) Then strTitle = "Logon Error" strText = "Log cannot be written." strText = strText & vbCrlf _ & "Another process may have log file open." intConstants = vbOKOnly + vbExclamation intAns = objShell.Popup(strText, intTimeout, strTitle, _ intConstants) End If objLogFile.Close Else On Error GoTo 0 strTitle = "Logon Error" strText = "Log cannot be written." strText = strText & vbCrLf & "User may not have permissions," strText = strText & vbCrLf & "or log folder may not be shared." intConstants = vbOKOnly + vbExclamation intAns = objShell.Popup(strText, intTimeout, strTitle, intConstants) End If End If Function GetIP() Dim ws : Set ws = CreateObject("WScript.Shell") Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt" Dim ThisLine, IP If ws.Environment("SYSTEM")("OS") = "" Then ws.run "winipcfg /batch " & TmpFile, 0, True Else ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True End If With fso.GetFile(TmpFile).OpenAsTextStream Do While NOT .AtEndOfStream ThisLine = .ReadLine If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2) Loop .Close End With 'WinXP (NT? 2K?) leaves a carriage return at the end of line If IP <> "" Then If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1) End If GetIP = IP fso.GetFile(TmpFile).Delete Set fso = Nothing Set ws = Nothing End Function LogOff.vbs - Option Explicit Dim objFSO, objLogFile, objNetwork, objShell, strText, intAns, strComputer, objWMIService, colChassis, strChassisType,strType, objChassis Dim intConstants, intTimeout, strTitle, intCount, blnLog Dim strUserName, strComputerName, strIP, strShare, strLogFile strShare = "\\servername\Audit-LogOff" strLogFile = "logoff.csv" intTimeout = 20 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objNetwork = CreateObject("Wscript.Network") Set objShell = CreateObject("Wscript.Shell") strUserName = objNetwork.UserName strComputerName = objNetwork.ComputerName strIP = GetIP() ''''''''''''''''''''''''''''''''''''' strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colChassis = objWMIService.ExecQuery _ ("Select * from Win32_SystemEnclosure") For Each objChassis in colChassis For Each strChassisType in objChassis.ChassisTypes Select Case strChassisType Case 1 strType = "Other" Case 2 strType = "Unknown" Case 3 strType = "Desktop" Case 4 strType = "Low Profile Desktop" Case 5 strType = "Pizza Box" Case 6 strType = "Mini Tower" Case 7 strType = "Tower" Case 8 strType = "Portable" Case 9 strType = "Laptop" Case 10 strType = "Notebook" Case 11 strType = "Handheld" Case 12 strType = "Docking Station" Case 13 strType = "All-in-One" Case 14 strType = "Sub-Notebook" Case 15 strType = "Space Saving" Case 16 strType = "Lunch Box" Case 17 strType = "Main System Chassis" Case 18 strType = "Expansion Chassis" Case 19 strType = "Sub-Chassis" Case 20 strType = "Bus Expansion Chassis" Case 21 strType = "Peripheral Chassis" Case 22 strType = "Storage Chassis" Case 23 strType = "Rack Mount Chassis" Case 24 strType = "Sealed-Case PC" Case Else strType = "Unknown" End Select Next Next '''''''''''''''''''''''''''''''''''''''' ' Log date/time, user name, computer name, and IP address, computer Type If (objFSO.FolderExists(strShare) = True) Then On Error Resume Next Set objLogFile = objFSO.OpenTextFile(strShare & "\" _ & strLogFile, 8, True, 0) If (Err.Number = 0) Then ' Make three attempts to write to log file. intCount = 1 blnLog = False Do Until intCount = 3 objLogFile.WriteLine "Logoff," & Now & "," _ & strComputerName & "," & strUserName & "," & strIP & "," & strType If (Err.Number = 0) Then intCount = 3 blnLog = True Else Err.Clear intCount = intCount + 1 If (Wscript.Version > 5) Then Wscript.Sleep 200 End If End If Loop On Error GoTo 0 If (blnLog = False) Then strTitle = "Logoff Error" strText = "Log cannot be written." strText = strText & vbCrlf _ & "Another process may have log file open." intConstants = vbOKOnly + vbExclamation intAns = objShell.Popup(strText, intTimeout, strTitle, _ intConstants) End If objLogFile.Close Else On Error GoTo 0 strTitle = "Logoff Error" strText = "Log cannot be written." strText = strText & vbCrLf & "User may not have permissions," strText = strText & vbCrLf & "or log folder may not be shared." intConstants = vbOKOnly + vbExclamation intAns = objShell.Popup(strText, intTimeout, strTitle, intConstants) End If End If Function GetIP() Dim ws : Set ws = CreateObject("WScript.Shell") Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt" Dim ThisLine, IP If ws.Environment("SYSTEM")("OS") = "" Then ws.run "winipcfg /batch " & TmpFile, 0, True Else ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True End If With fso.GetFile(TmpFile).OpenAsTextStream Do While NOT .AtEndOfStream ThisLine = .ReadLine If InStr(ThisLine, "Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2) Loop .Close End With 'WinXP (NT? 2K?) leaves a carriage return at the end of line If IP <> "" Then If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1) End If GetIP = IP fso.GetFile(TmpFile).Delete Set fso = Nothing Set ws = Nothing End FunctionRakesh Kumar
Free Windows Admin Tool Kit Click here and download it now
June 7th, 2012 8:39am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics