Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Clears Run History in FIMSynchronizationService after saving to xml file.
Clears run history in FIM Synchronization Service and stores the history.
The Number of days to keep.
.PARAMETER exportDirectory
The folder where deleted history is saved.
PARAM([int]$dayDiff=7, [string]$exportDirectory="F:\IAM\Logs\RunHistory\")
#Set delete date
$dateNow = Get-Date -Format yyyy-MM-dd_HHmm
$dateDelete = (Get-Date).AddDays(-$dayDiff)
#Export run history before deleting
$filePathName = $exportDirectory + "RunHistory_" + $dateNow + “.xml”
$run = New-Object xml
$finalXML = "<run-history>"
$lstRuns = @(get-wmiobject -class “MIIS_RunHistory” -namespace “root\MicrosoftIdentityIntegrationServer” -computer “.”)
$lstRuns | ForEach-Object {
if([datetime]$_.RunEndTime -lt $dateDelete)
$finalXML += $run.'run-history'.InnerXml
$finalXML += "</run-history>"
#Delete the run history before delete date
$lstSrv = @(get-wmiobject -class “MIIS_SERVER” -namespace “root\MicrosoftIdentityIntegrationServer” -computer “.”)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment