Identifying Windows Live Messenger Logins

Posted on Updated on

We have implemented Microsoft Lync in our environment and are preparing to “federate” our domain.  When this happens, users whom have set up a Windows Live ID using their company email address, will no longer be able to use Messenger.  I created the following script which will get the login email address from Messenger as well as the last login time then output the information to a text file on a file share.

' AUTHOR: Nick Moseley,
' DATE  : 10/20/2011
Option Explicit
Const ForAppending = 8
On Error Resume Next

Dim oShell, oFSO, oUserDir, colSubFolders
Dim strProfileFolder, strAppFolder
Set oShell = CreateObject ("")
Set oFSO = CreateObject ("Scripting.FileSystemObject")

If oFSO.FolderExists ("c:\users") Then
	strProfileFolder = "c:\users"
	strAppFolder = "\AppData\Local\Microsoft\Messenger"
	strProfileFolder = "c:\Documents and Settings"
	strAppFolder = "\Local Settings\Application Data\Microsoft\Messenger"
End If

Set oUserDir = oFSO.GetFolder (strProfileFolder)
Set colSubFolders = oUserDir.SubFolders

' Open log file
Dim sFileName, oLogFile
sFileName = "\\engsvr01\pstlogs\SCCM\" & oshell.ExpandEnvironmentStrings("%COMPUTERNAME%") & ".txt"
If not oFSO.FileExists (sFileName) Then
	oFSO.CreateTextFile sFileName
End If

Set oLogFile = oFSO.OpenTextFile (sFileName, ForAppending, True)
oLogFile.WriteLine "====Started: " & Date & "===="
oLogFile.WriteLine " " 

' For User folders, check for Windows
Dim oFldr, oFldr2, oWLMfolders, colWLMusers, oConfigFile, sFolderPath
For Each oFldr In colSubFolders
	sFolderPath = strProfileFolder & "\" & oFldr.Name & strAppFolder
	' if the Messenger folder exists, then do the following
	If oFSO.FolderExists (sFolderPath) Then
		Set oWLMfolders = oFSO.GetFolder (sFolderPath)
		Set colWLMusers = oWLMfolders.SubFolders
		' if the subfolders contains the config.cache file, then it was signed into on WLM
		For Each oFldr2 In colWLMusers
			oLogFile.WriteLine "User: " & oFldr.Name 
			oLogFile.WriteLine "Email: " & oFldr2.Name
			If oFSO.FileExists (sFolderPath & "\" & oFldr2.Name & "\config.cache.xml") Then
				' Set oConfigFile to get file's timestamp
				Set oConfigFile = oFSO.GetFile (sFolderPath & "\" & oFldr2.Name & "\config.cache.xml")
				'oLogFile.WriteLine "User: " & oFldr.Name 
				'oLogFile.WriteLine "Email: " & oFldr2.Name
				oLogFile.WriteLine "Last signin: " & oConfigFile.DateLastModified
				oLogFile.WriteLine "Last signin: UNKNOWN" 
			End If
			oLogFile.WriteLine " " 
	End If

' end logging
oLogFile.WriteLine "====Ended===="
oLogFile.WriteLine " " 
WScript.Quit (oLogFile.Close)

Since not all computers will have used Messenger, let alone a person having logged into Messenger, create a collection that will be limited to just computers that have recently executed “msnmsgr.exe”.  You can use the below query to determine those systems for your collection.

select distinct SMS_R_System.Name
from  SMS_R_System
on SMS_G_System_CCM_RECENTLY_USED_APPS.ResourceID = SMS_R_System.ResourceId
where SMS_G_System_CCM_RECENTLY_USED_APPS.ExplorerFileName = "msnmsgr.exe"
order by SMS_R_System.Name

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s