If you implement How can I record logon and logoff information in both the user account description and the computer account description?, you can use getUdesc.vbs to determine a user's is logon status and getCdesc.vbs to determine a computer's user status.

The syntax for using getUdesc.vbs is:

cscript //nologo Drive:\Folder\getudesc.vbs User

Where User is the NetBIOS user name, or a wildcard expression of the NetBIOS user name. if User is Jerry, then the output is a CSV formatted line like:

<b>"Jerry";"CN=Jerold Schulman,CN=Users,DC=JSIINC,DC=ORG";"ON 20060516 074011;JSI009;CN=JSI009,CN=Computers,DC=JSIINC,DC=COM;OFF 00000000 000000"</b>If User is J*, then all users who's sAMAccountName starts with J are displayed. If User is *, all users are displayed.

NOTE: Users who have NOT logged on since tip 10492 was implemented are NOT displayed.

The syntax for using getCdesc.vbs is:

cscript //nologo Drive:\Folder\getcdesc.vbs Computer

Where Computer is the NetBIOS computer name, or a wildcard expression of the NetBIOS computer name. if Computer is JSI009, then the output is a CSV formatted line like:

<b>"JSI009";"CN=JSI009,CN=Computers,DC=JSIINC,DC=ORG";"ON 20060516 074011;Jerry;CN=Jerold Schulman,CN=Users,DC=JSIINC,DC=COM;OFF 00000000 000000"</b>If computer is J*, then all computer who's Name starts with J are displayed. If computer is *, all computers are displayed.

NOTE: Computers that have NOT been logged onto since tip 10492 was implemented are NOT displayed.

getUdesc.vbs contains:

On Error Resume Next
Dim objConnection, objCommand, objRootDSE, strDNSDomain
Dim strFilter, strQuery, objRecordSet, objArgs, objUser
Set objArgs = Wscript.Arguments
if objArgs.Count = 0 then
 Wscript.Echo  "sAMAccountName argument required. ""Jerry"" or ""*"" or ""J*"" or etc.."
 WScript.Quit (1)
End If
sam = objArgs(0)
Set oShell = CreateObject( "WScript.Shell" )
domain =oShell.ExpandEnvironmentStrings("%USERDOMAIN%")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOOBject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Set objRootDSE = GetObject("LDAP://RootDSE")
'Get domain
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
'Define the filter elements
strFilter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName=" & sam & "))"
'List all attributes you will require
strAttributes = "sAMAccountName,distinguishedName"
'compose query
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 99999
objCommand.Properties("Timeout") = 300
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    strSA = objRecordSet.Fields("sAMAccountName")
    strDN = objRecordSet.Fields("distinguishedName")
    strDomainUser = domain & "/" & strSA
    Set objUser = GetObject("WinNT://" & strDomainUser )
    Desc = objUser.Description
    wrk1 = inStr(Desc, "ON ")
    wrk2 = inStr(Desc, ";OFF ")
    if wrk1 = 1 AND wrk2 > 1 Then
        Wscript.Echo <div class="Contentquote"><center>" & strSA & </center></div>;<div class="Contentquote"><center> & strDN  & </center></div>;<div class="Contentquote"><center> & Desc  & </center></div>"
    End If
    objRecordSet.MoveNext
Loop
' Clean up.
objConnection.Close
Set objConnection = Nothing
Set objCommand = Nothing
Set objRootDSE = Nothing
Set objRecordSet = Nothing
getCdesc.vbs contains:
On Error Resume Next
Dim objConnection, objCommand, objRootDSE, strDNSDomain
Dim strFilter, strQuery, objRecordSet, objArgs, objUser
Set objArgs = Wscript.Arguments
if objArgs.Count = 0 then
 Wscript.Echo  "Computer Name argument required. ""JSI001"" or ""*"" or ""J*"" or etc.."
 WScript.Quit (1)
End If
sam = objArgs(0)
Set oShell = CreateObject( "WScript.Shell" )
domain =oShell.ExpandEnvironmentStrings("%USERDOMAIN%")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOOBject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Set objRootDSE = GetObject("LDAP://RootDSE")
'Get domain
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
'Define the filter elements
strFilter = "(&(objectCategory=computer)(objectClass=computer)(Name=" & sam & "))"
'List all attributes you will require
strAttributes = "Name,distinguishedName,sAMAccountName"
'compose query
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 99999
objCommand.Properties("Timeout") = 300
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    strSA = objRecordSet.Fields("Name")
    strDN = objRecordSet.Fields("distinguishedName")
    strSac = objRecordSet.Fields("sAMAccountName")
    strDomainCmp = domain & "/" & strSAc
    Set objCmp = GetObject("WinNT://" & strDomainCmp)
    Desc = objCmp.Description
    wrk1 = inStr(Desc, "ON ")
    wrk2 = inStr(Desc, ";OFF ")
    if wrk1 = 1 AND wrk2 > 1 Then
        Wscript.Echo <div class="Contentquote"><center>" & strSA & </center></div>;<div class="Contentquote"><center> & strDN  & </center></div>;<div class="Contentquote"><center> & Desc  & </center></div>"
    End If
    objRecordSet.MoveNext
Loop
' Clean up.
objConnection.Close
Set objConnection = Nothing
Set objCommand = Nothing
Set objRootDSE = Nothing
Set objRecordSet = Nothing