Skip to content

Querying FIM WMI metrics with PowerShell

There has been a WMI way to get info about the Sync service, MAs and connector space objects since the MIIS days. There used to be a bunch of vbscript samples on TechNet but I’ve never seen them updated for PowerShell. The other day I wanted to produce a report of MA stats and thought I’d be able to find an example to use – but I couldn’t so did it myself. Here’s my example script showing some of the useful info you can query with WMI.

PARAM ($LogFile)
$FIMServer = get-wmiobject -Namespace "root\MicrosoftIdentityIntegrationServer" -class "MIIS_Server"
$FIMMAs = get-wmiobject -Namespace "root\MicrosoftIdentityIntegrationServer" -class "MIIS_ManagementAgent"
$FIMRunHistory = get-wmiobject -Namespace "root\MicrosoftIdentityIntegrationServer" -class "MIIS_RunHistory"

Function WriteLog
{
    PARAM($Message)
    END
    {
        write-host $Message
        $Message | Add-Content $LogFile
    }
}

Out-File -FilePath $LogFile -Encoding "Default"

foreach ($MA in $FIMMAs)
{
    WriteLog ($MA.Name)
    WriteLog ("Type: " + $MA.Type)
    WriteLog ("Connector Space:")
    WriteLog ("`tCSObjects: " + $MA.NumCSObjects().ReturnValue)
    WriteLog ("`t`tConnectors: " + $MA.NumTotalConnectors().ReturnValue)
    WriteLog ("`t`t`tManual Joins: " + $MA.NumExplicitConnectors().ReturnValue)
    WriteLog ("`t`tDisconnectors: " + $MA.NumTotalDisconnectors().ReturnValue)
    WriteLog ("`t`t`tExplicit Disconnectors: " + $MA.NumExplicitDisconnectors().ReturnValue)
    WriteLog ("`t`t`tFiltered Disconnectors: " + $MA.NumFilteredDisconnectors().ReturnValue)
    WriteLog ("`t`tPlaceholders: " + $MA.NumPlaceholders().ReturnValue)
    WriteLog ("`tPendingExports:")
    WriteLog ("`t`tAdds: " + $MA.NumExportAdd().ReturnValue)
    WriteLog ("`t`tDeletes: " + $MA.NumExportDelete().ReturnValue)
    WriteLog ("`t`tUpdates: " + $MA.NumExportUpdate().ReturnValue)
    WriteLog ("`n")
    WriteLog ("Run History:")
    $rh = $FIMRunHistory | where {$_.MaName -eq $MA.Name}
    foreach ($run in $rh) { WriteLog ("`t" + $run.RunProfile + " " + $run.RunStartTime + " " + $run.RunStatus) }
    WriteLog ("`n")
    WriteLog ("`tLast Run Errors:")
    [xml]$rd = $MA.RunDetails().ReturnValue
    $ImportErrors = $rd."run-history"."run-details"."step-details"."synchronization-errors"."import-error"
    WriteLog ("`tError`tDN`tSince")
    foreach ($importErr in $ImportErrors) { WriteLog ("`t" + $importErr."error-type" + " " + $importErr."dn" + " " + $importErr."first-occurred") }
    WriteLog ("`n")
    WriteLog ("`n")
}

{ 3 } Comments

  1. Mujeeb | May 13, 2013 at 5:19 am | Permalink

    Carol this is an awesome script !!! Thanks for sharing :)

  2. Andrew | August 23, 2013 at 9:43 am | Permalink

    Great, thank you!

  3. Dieter | April 4, 2014 at 5:16 am | Permalink

    Awesome!

Post a Comment

Your email is never published nor shared. Required fields are marked *

Spam comments will be blocked by Akismet

*

Prednisone on line buy Prednisone overnight buy cheap Prednisone online free consult buy Prednisone on line amex uk buy Prednisone buy cod Prednisone order overnight Prednisone medikament Prednisone Prednisone order online buy Prednisone no scams buy Prednisone mastercard online purchase Prednisone buy cheap Prednisone no prescription buy Prednisone amex online without rx buy Prednisone canada purchasing Prednisone without a script where to buy generic Prednisone online without a prescription Prednisone drug non rx cheap Prednisone order Prednisone cheap overnight fedex Prednisone overnight without a prescription buy Prednisone 20 mg buy Prednisone where Prednisone without prescription overnight shipping purchasing Prednisone without a script Prednisone without rx overnight shipping where to purchase Prednisone no prescription no fees Prednisone online overnight delivery cod Prednisone prescription order order Prednisone without rx from us pharmacy buy Prednisone pills in toronto buy Prednisone online online pharmacies Prednisone buy Prednisone no prescriptions buy Prednisone once a day order Prednisone pay pal online without rx buy Prednisone where buy line Prednisone best finpecia online pill buy Maxalt us pharmacy Maxalt buy Maxalt with visa Cytotec purchase overnight delivery where buy Lisinopril purchasing finpecia with overnight delivery no prescription requip buy requip over the counter where can i order requip online how to get arimidex arimidex cheap online Lisinopril overnight cod cheap order rx metformin prednisone 40 mg cheapest place to buy Metformin purchase Metformin online Maxalt no prescription needed 10mg Maxalt 10mg canada where to buy Maxalt uk buy generic Maxalt canada buy metformin cod ordering Requip online non prescription Requip Requip without script Requip with no rx where to buy Requip Requip online no prescription buy generic Requip australia canadian pharmacy no prescription Requip Requip no rx buy generic Requip online no prescription buy cheap Maxalt under without rx buy on line Maxalt where can i buy Maxalt buy pharmacy Maxalt waterview buy maxalt online no prescription buy Maxalt visa buy Maxalt pills online maxalt buy buy Maxalt pills buy Maxalt shipped cod buy Maxalt cod Maxalt purchase online Maxalt purchase online where to buy generic maxalt online without a rx buy Maxalt with no prescription Lisinopril no prescription buy cheap Lisinopril buy cheap generic Lisinopril how to buy Metformin without a prescription Metformin price buy Alli without prescription