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

*

Endep online order order buy Endep online purchase Endep online without script buy generic Endep from india buy in Endep uk where to buy Endep without a prescription Endep from canada buy 10 mg Aricept generic Aricept cost order Nizoral no visa Nizoral 200 mg buy cheap Nizoral line Nizoral on line best finpecia online pill Requip Requip free Requip uk Amitriptyline generic buy generic Amitriptyline from india where buy Lisinopril purchasing finpecia with overnight delivery Nizoral online buy saturday delivery buy Nizoral in mo finpecia online how to buy Cytotec online without a rx order Aricept pharmacy buy Aricept with no prescription buy Amitriptyline no perscription cod Online us Requip how to buy Amitriptyline without a prescription buy line Amitriptyline buy Amitriptyline money buy purchase Accutane 40 mg on line no rx Accutane 40 mg sale order 40 mg Accutane online next day delivery 40 mg Accutane online buy Lisinopril pay cod Lisinopril overnight cod buy lisinopril without prescription buy lisinopril purchase Premarin cod next day delivery where buy Premarin buy Premarin online free fedex delivery Premarin cheapest place to buy Metformin purchase Metformin online generic 20mg prednisone online finpecia online overnight buy finpecia cheap buy Metformin toronto Metformin prescription buy Metformin where metformin purchased online without prescription buy metformin online cod purchase metformin money purchase order Metformin usa buy metformin cash on delivery how to order prednisone online without a prescription online prescriptions prednisone buy online rx finpecia without fedex finpecia overnight without a prescription buy Metformin discount can i order finpecia onlinebuy finpecia cheap prednisone prescription cost Metformin canadian pharmacy buy cheap generic Metformin online lisinopril buy lisinopril