{"id":867,"date":"2010-07-19T09:52:38","date_gmt":"2010-07-19T09:52:38","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=867"},"modified":"2010-07-19T11:21:13","modified_gmt":"2010-07-19T11:21:13","slug":"querying-the-fim-metaverse-using-powershell","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/querying-the-fim-metaverse-using-powershell","title":{"rendered":"Querying the FIM Metaverse using powershell"},"content":{"rendered":"<p>It&#8217;s actually pretty easy to query SQL 2008 from powershell.<\/p>\n<p>This simple little script reads employeeID numbers from a text file and then queries\u00c2\u00a0the metaverse for selected\u00c2\u00a0attributes. The text file must have &#8220;id&#8221; as the first row, with the id numbers then listed one per line.<!--more--><\/p>\n<div><\/div>\n<p><code><\/p>\n<pre>if(@(get-pssnapin | where-object {$_.Name -eq \u00e2\u20ac\u0153sqlserverprovidersnapin100\u00e2\u20ac\u009d} ).count -eq 0) {add-pssnapin sqlserverprovidersnapin100}\r\nif(@(get-pssnapin | where-object {$_.Name -eq \u00e2\u20ac\u0153sqlservercmdletsnapin100\u00e2\u20ac\u009d} ).count -eq 0) {add-pssnapin sqlservercmdletsnapin100}\r\n\r\nset-location SQLSERVER:\\SQL\\localhost\\DEFAULT\\Databases\\FIMSynchronizationService\r\n$List = Import-Csv -Path C:\\scripts\\employeeids.txt\r\n\r\nforeach ($row in $List)\r\n{\r\n$SqlQuery = \"select employeeID,displayName,mail from mms_metaverse where employeeID = '$($row.id)'\"\r\nInvoke-SQLCmd $SqlQuery -SuppressProviderContextWarning\r\n}<\/pre>\n<p>\u00c2\u00a0<\/p>\n<p><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s actually pretty easy to query SQL 2008 from powershell. This simple little script reads employeeID numbers from a text file and then queries\u00c2\u00a0the metaverse for selected\u00c2\u00a0attributes. The text file must have &#8220;id&#8221; as the first row, with the id numbers then listed one per line.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","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,23,5],"tags":[],"class_list":["post-867","post","type-post","status-publish","format-standard","hentry","category-fim-2010","category-powershell","category-sql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-dZ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/867","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=867"}],"version-history":[{"count":2,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/867\/revisions"}],"predecessor-version":[{"id":870,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/867\/revisions\/870"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}