Dim
Service
ManagementAgent
DeleteDate
Set
Service = GetObject(
"winmgmts:\root\MicrosoftIdentityIntegrationServer"
)
Server = Service.
Get
(
"MIIS_Server.Name='MIIS_Server1'"
'// DeleteDate the date to use for the deletion of runs
DeleteDate = GETDELETEDATE(
Date
() - 1 )
WScript.Echo
"Deleting Run Histories from "
& DeleteDate
"Result: "
& Server.ClearRuns(DeleteDate)
'// ======================================================================
'// FUNCTION IIF
'// PURPOSE: To be able to execute an If...Then...Else statement on a single line
'// -- conditionalString: is the conditional statement to check via the IF
'// -- TrueString: if the condition is true, the statement to execute
'// -- FalseString: if the condition is false, the statement to execute
FUNCTION IIF(conditionalString, TrueString, FalseString)
IF conditionalString THEN
IIF = TrueString
ELSE
IIF = FalseString
END IF
END FUNCTION
'// ====================================================================
'// FUNCTION GETDELETEDATE
'// PURPOSE: The date has to be formatted in a special way to work with the sync engine.
'// using this function to help format the date.
FUNCTION GETDELETEDATE( TheDeleteDate )
GETDELETEDATE = YEAR(TheDeleteDate) &
"-"
& IIF(LEN(MONTH(TheDeleteDate))=1,
"0"
& MONTH(TheDeleteDate), MONTH(TheDeleteDate)) &
& IIF(LEN(DAY(TheDeleteDate))=1,
& DAY(TheDeleteDate), DAY(TheDeleteDate))