This HTA script will allow you to enter a server name and site code into the provided text boxes and will enumerate all of the machines and their last logged on user name as well as the Heartbeat discovery agents time stamp.
Machine Name
User Name
Time Stamp
Machine One
User A
4/15/2008 3:04:50 PM
Machine Two
User B
4/11/2008 11:39:46 AM
Machine Three
User C
4/15/2008 4:17:34 PM
Machine Four
User D
2/19/2008 9:19:01 AM
Machine Five
User E
2/29/2008 9:49:17 PM
HTA Script:
<Html>
<Head>
<Title>HTA Script</Title>
<Style>
Body {Background-Color: CornSilk}
</Style>
<HTA:Application
Caption = Yes
Border = Thick
ShowInTaskBar = No
MaximizeButton = Yes
MinimizeButton = Yes>
<script Language = VBScript>
Window.Document.Title = "Heartbeat Discovery Information"
Sub WindowsLoad
strSqlServer = SqlServer.value
strDatabase = Database.value
strHTML = "<table border='1' style='border-collapse: collapse' bordercolor='SaddleBrown' id='Table1' >"
strHTML = strHTML & "<tr>"
strHTML = strHTML & "<br>"
strHTML = strHTML & "<td width='10%' bgcolor = 'SeaShell'><font color = 'Blue'><b>Machine Name</td>"
strHTML = strHTML & "<td width='10%' bgcolor = 'SeaShell'><font color = 'Blue'><b>User Name</td>"
strHTML = strHTML & "<td width='10%' bgcolor = 'SeaShell'><font color = 'Blue'><b>Time Stamp</td>"
strHTML = strHTML & "</tr>"
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open "Provider=SQLOLEDB;Data Source =" & strSqlServer & ";" & _
"Trusted_Connection=Yes;Initial Catalog =SMS_" & strDatabase
objRecordSet.Open _
"Select SD.Name0, SD.User_Name0, AN.AgentTime, " & _
"AN.AgentName From v_R_System SD " & _
"Join v_AgentDiscoveries AN on SD.ResourceID = AN.ResourceId " & _
"Where AN.AgentSite = 'XXX' And AN.AgentName = 'Heartbeat Discovery' " & _
"Group By SD.Name0, SD.User_Name0, AN.AgentTime, AN.AgentName " & _
"Order By SD.Name0 ", objConnection, adOpenStatic, adLockOptimistic
On Error Resume Next
objRecordSet.MoveFirst
Do Until objRecordset.EOF
Window.Document.Title = UCase(GetItems.Value) & " - Collection User Information "
strHTML = strHTML & "<td width='1%'>" & objRecordset.Fields.Item("Name0") & "</td>"
strHTML = strHTML & "<td width='1%'>" & objRecordset.Fields.Item("User_Name0") & "</td>"
strHTML = strHTML & "<td width='1%'>" & objRecordset.Fields.Item("AgentTime") & "</td>"
objRecordset.MoveNext
Loop
objRecordSet.Close
objConnection.Close
strHTML = strHTML & "</table>"
DataArea.InnerHTML = strHTML
End Sub
</script><Body>
<p><h3 align = center><font color='Orange'>Please Visit myITforum.Com</font></h3><div></div>
SQL Server Name: <Input Type = "Text" Name = "SqlServer">
Database Name: <Input Type = "Text" Name = "Database">
<input id=DisplayButton class="button" type="button" value="Run Script" name="DisplayItems_button" onClick="WindowsLoad">
</body></html>
<Span Id = "DataArea"></Span></Body><Div Align = "Center">
<P><A Href="http://myitforum.com/cs2/blogs/dhite">Created For myITforum By Don Hite</A>
No Comments