none
I could not save and delete run_history of MIIS

    General discussion

  • I use the script below and it worked fine.

    But recently  I get the following error and script fail.

    How could I solve the error ?

    C:\Program Files\Microsoft Identity Integration Server\CMD\Delete_RunHistoryR2.vbs(66, 5) SWbemObjectEx: エラーです

    ' 定数宣言
    Const CONVERT_TO_LOCAL_TIME = True
    Const CONVERT_TO_UTC = False

    ' 変数宣言
    Dim objArgs
    Dim Service
    Dim Server
    Dim Runs
    Dim Run
    Dim TZ
    Dim DeleteDate

    ' コマンドライン引数の解析
    Set objArgs = WScript.Arguments

    'For I = 0 to objArgs.Count - 1
    '   WScript.Echo objArgs(I)
    'Next

    ' コマンドライン引数(削除開始日付)の検証
    If objArgs.Count = 0 Then
        NonParmMessage
        WScript.Quit(9)
    End If
    If not IsNumeric(objArgs(0)) Then
        NonParmMessage
        WScript.Quit(-1)
    End If
    IF objArgs(0) <= 5 Then
        NonParmMessage
        WScript.Quit(-1)
    End If

    DateToCheck = DateAdd("d", objArgs(0) * -1 -1 , Date)

    ' TimeZoneの取得
    strComputer = "."
    Set objSWbemServices = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colTimeZone = objSWbemServices.ExecQuery ("SELECT * FROM Win32_TimeZone")

    For Each objTimeZone in colTimeZone
    '    Wscript.Echo "Offset: "& objTimeZone.Bias
        Set TZ = objTimeZone
    Next

    ' MIIS Serviceオブジェクトの取得
    Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
    Set Service = GetObject("winmgmts:root\MicrosoftIdentityIntegrationServer")

    dtmStartDate.SetVarDate DateToCheck, CONVERT_TO_LOCAL_TIME
    dtmRegular = dtmStartDate.GetVarDate()
    dtmNew = DateAdd("n", - (Int(TZ.Bias)), dtmRegular)

    DeleteDate = Year(dtmNew) & "-" & Right("00" & Month(dtmNew), 2) & "-" & Right( "00" & Day(dtmNew), 2) & " " & Right( "00" & Hour(dtmNew), 2) & ":" & Right( "00" & Minute(dtmNew), 2) & ":" & Right( "00" & Second(dtmNew), 2)

    'WScript.Echo dtmRegular & vbcr
    strQuery = "Select * From MIIS_RunHistory Where RunStartTime < '" & DeleteDate & "'"
    'WScript.Echo strQuery & vbcr

    Set Runs = Service.ExecQuery(strQuery)

    For Each Run in Runs
    '    WScript.Echo Run.MaName & vbcr
    '    WScript.Echo "Run History: " & Run.Key & vbcr
        WScript.Echo Run.RunDetails()
    Next

    'MIIS Server オブジェクトの取得
    Set Server = Service.Get("MIIS_Server.Name='MIIS_Server1'")
    '処理開始宣言
    WScript.Echo "Deleting Run Histories from " & DeleteDate & ".000"
    'ClearRunsメソッドによるRun History の削除
    WScript.Echo "Result: " & Server.ClearRuns(DeleteDate & ".000")

    'Server オブジェクト開放
    Set Server = Nothing

    Sub NonParmMessage()
        WScript.Echo "パラメータ(何日より前のログを削除するか)を指定してください。"
        WScript.Echo "5(日)以下は指定できません。"
    End Sub

    Tuesday, November 13, 2012 7:44 AM

All replies

  • I read a lot of chinese characters, is it possible to replace them by English for a more readable message, further more i don't seen the error message anywhere (probably because it is in chinese :))


    Need realtime FIM synchronization and advanced reporting? check out the new http://www.imsequencer.com that supports FIM 2010, Omada Identity Manager, SQL, File, AD or Powershell real time synchronization!

    Tuesday, November 13, 2012 8:38 AM
  • It seems somewhere on line 66 and char 5 what is the line in the script, is is Run.RunDetails()? if you leave it out, will the script then run correctly?

    Need realtime FIM synchronization and advanced reporting? check out the new http://www.imsequencer.com that supports FIM 2010, Omada Identity Manager, SQL, File, AD or Powershell real time synchronization!

    Wednesday, November 14, 2012 5:59 AM
  • And are you sure nothing has changed? I would go back to the point where the history is deleted and see where things go wrong.

    Need realtime FIM synchronization and advanced reporting? check out the new http://www.imsequencer.com that supports FIM 2010, Omada Identity Manager, SQL, File, AD or Powershell real time synchronization!

    Wednesday, November 14, 2012 7:56 AM
  • Miyagiken,

    Your co-worker might be referring to issue when a profile run didn't complete. So end_date field in SQL is still NULL. To delete the row out of the run history, this field must be populated. I would of course always advise making backups but you can update just that row that is in this state and then run script again, that will fix problem.

    I believe the table is mms_run_history, but you should look for thisfield being NULL and update it. Again, do NOT do this until you hvae created a backup of the sync DB.

    Thursday, November 15, 2012 4:24 AM