{"id":2489,"date":"2013-01-24T02:51:23","date_gmt":"2013-01-24T02:51:23","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=2489"},"modified":"2013-01-24T02:52:55","modified_gmt":"2013-01-24T02:52:55","slug":"querying-fim-wmi-metrics-with-powershell","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/querying-fim-wmi-metrics-with-powershell","title":{"rendered":"Querying FIM WMI metrics with PowerShell"},"content":{"rendered":"<p>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&#8217;ve never seen them updated for PowerShell. The other day I wanted to produce a report of MA stats and thought I&#8217;d be able to find an example to use &#8211; but I couldn&#8217;t so did it myself. Here&#8217;s\u00c2\u00a0my example script showing some of the useful\u00c2\u00a0info you can query with WMI.<!--more--><\/p>\n<pre>PARAM ($LogFile)\r\n$FIMServer = get-wmiobject -Namespace \"root\\MicrosoftIdentityIntegrationServer\" -class \"MIIS_Server\"\r\n$FIMMAs = get-wmiobject -Namespace \"root\\MicrosoftIdentityIntegrationServer\" -class \"MIIS_ManagementAgent\"\r\n$FIMRunHistory = get-wmiobject -Namespace \"root\\MicrosoftIdentityIntegrationServer\" -class \"MIIS_RunHistory\"\r\n\r\nFunction WriteLog\r\n{\r\n    PARAM($Message)\r\n    END\r\n    {\r\n        write-host $Message\r\n        $Message | Add-Content $LogFile\r\n    }\r\n}\r\n\r\nOut-File -FilePath $LogFile -Encoding \"Default\"\r\n\r\nforeach ($MA in $FIMMAs)\r\n{\r\n    WriteLog ($MA.Name)\r\n    WriteLog (\"Type: \" + $MA.Type)\r\n    WriteLog (\"Connector Space:\")\r\n    WriteLog (\"`tCSObjects: \" + $MA.NumCSObjects().ReturnValue)\r\n    WriteLog (\"`t`tConnectors: \" + $MA.NumTotalConnectors().ReturnValue)\r\n    WriteLog (\"`t`t`tManual Joins: \" + $MA.NumExplicitConnectors().ReturnValue)\r\n    WriteLog (\"`t`tDisconnectors: \" + $MA.NumTotalDisconnectors().ReturnValue)\r\n    WriteLog (\"`t`t`tExplicit Disconnectors: \" + $MA.NumExplicitDisconnectors().ReturnValue)\r\n    WriteLog (\"`t`t`tFiltered Disconnectors: \" + $MA.NumFilteredDisconnectors().ReturnValue)\r\n    WriteLog (\"`t`tPlaceholders: \" + $MA.NumPlaceholders().ReturnValue)\r\n    WriteLog (\"`tPendingExports:\")\r\n    WriteLog (\"`t`tAdds: \" + $MA.NumExportAdd().ReturnValue)\r\n    WriteLog (\"`t`tDeletes: \" + $MA.NumExportDelete().ReturnValue)\r\n    WriteLog (\"`t`tUpdates: \" + $MA.NumExportUpdate().ReturnValue)\r\n    WriteLog (\"`n\")\r\n    WriteLog (\"Run History:\")\r\n    $rh = $FIMRunHistory | where {$_.MaName -eq $MA.Name}\r\n    foreach ($run in $rh) { WriteLog (\"`t\" + $run.RunProfile + \" \" + $run.RunStartTime + \" \" + $run.RunStatus) }\r\n    WriteLog (\"`n\")\r\n    WriteLog (\"`tLast Run Errors:\")\r\n    [xml]$rd = $MA.RunDetails().ReturnValue\r\n    $ImportErrors = $rd.\"run-history\".\"run-details\".\"step-details\".\"synchronization-errors\".\"import-error\"\r\n    WriteLog (\"`tError`tDN`tSince\")\r\n    foreach ($importErr in $ImportErrors) { WriteLog (\"`t\" + $importErr.\"error-type\" + \" \" + $importErr.\"dn\" + \" \" + $importErr.\"first-occurred\") }\r\n    WriteLog (\"`n\")\r\n    WriteLog (\"`n\")\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;ve never seen them updated for PowerShell. The other day I wanted to produce a report of MA stats and thought&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[42,60,15,23,61],"tags":[],"class_list":["post-2489","post","type-post","status-publish","format-standard","hentry","category-fim-2010","category-fim-2010-r2","category-ilm","category-powershell","category-reporting"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-E9","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=2489"}],"version-history":[{"count":4,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2489\/revisions"}],"predecessor-version":[{"id":2492,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2489\/revisions\/2492"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=2489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=2489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=2489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}