VBScript function to run profile “Profile” for management agent “MA”.
‘—————————————————–
‘ Function RunProfile
‘ + Run a MA run profile
‘ + Returns 0 for success
‘—————————————————–Function RunProfile(MA, Profile)
Dim ManagementAgent, Status
Dim runDetails, runResults
Dim xmlDoc, x
Dim iStart, iEnd
Dim numUpdates, numAdds, numDeletesIf MA = “” then Exit Function
WriteLog “Running ” & MA & ” ” & Profile
Set ManagementAgent = MIIS_Service.Get(“MIIS_ManagementAgent.Name=’”& MA &”‘”)Status = ManagementAgent.Execute(Profile)
WriteLog MA & “, ” & Profile & ” ” & ManagementAgent.RunStatusIf Status = “success” then
RunProfile = 0runDetails = ManagementAgent.RunDetails
iStart = InStr(runDetails, “<staging-counters>”)
iEnd = InStr(runDetails, “</staging-counters>”)
runDetails = Mid(runDetails, iStart, (iEnd+19) – iStart)Set xmlDoc = CreateObject(“Microsoft.XMLDOM”)
xmlDoc.async=”false”
xmlDoc.loadXML(runDetails)For Each x in xmlDoc.documentElement.childNodes
runResults = runResults & Mid(x.nodename,7) & “: ” & x.text & “, ”
NextWriteLog runResults
Else
RunProfile = -1
End ifEnd Function