The following script deletes information from the operation log up to the specified DeleteDate.

Visual Basic Script  Copy Code
Option Explicit

On Error Resume Next

Dim Service
Dim Server
Dim DeleteDate
Dim When

Set Service = GetObject("winmgmts:\root\MicrosoftIdentityIntegrationServer")
Set Server = Service.Get("MIIS_Server.Name='TEST'")

When = DateAdd("m", -1, Now)

DeleteDate = DatePart ("yyyy", When) & "-" & DatePart("m", when) & "-" & DatePart("d", when)

WScript.Echo "Deleting Run Histories from " & DeleteDate

WScript.Echo "Result: " & Server.ClearRuns(DeleteDate)

Sub ErrorHandler (ErrorMessage)
  WScript.Echo ErrorMessage
End Sub

See Also