{"id":2066,"date":"2012-07-02T08:19:10","date_gmt":"2012-07-02T08:19:10","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=2066"},"modified":"2012-07-02T08:19:10","modified_gmt":"2012-07-02T08:19:10","slug":"using-export-fimconfig-to-search-with-multiple-filters","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/using-export-fimconfig-to-search-with-multiple-filters","title":{"rendered":"Using Export-FIMConfig to search with multiple filters"},"content":{"rendered":"<p>I was trying to update a script so it could resolve references to various resource types. I&#8217;d seen in the help that you can do this:<\/p>\n<p><code>Export-FIMConfig -customConfig (\"\/ConstosoCustomResource\", \"\/Group\")<\/code><\/p>\n<p>So in my script I spent ages trying to construct a string like &#8220;(&#8220;\/ConstosoCustomResource&#8221;, &#8220;\/Group&#8221;)&#8221; and then wondering why it wouldn&#8217;t work.<\/p>\n<p><!--more--><\/p>\n<p>The answer was right there in the help all along &#8211; the customConfig parameter takes a string <em>array<\/em> as argument. D&#8217;uh!<\/p>\n<p>So here&#8217;s my function which returns the ObjectID based on DisplayName, where the object may be any of the types defined in $RefObjectTypes.<\/p>\n<p>&nbsp;<\/p>\n<pre>$RefObjecTypes = @('Person','Role','CostCentre')\r\n\r\nFunction ObjectReference\r\n{\r\n  PARAM($DisplayName)\r\n  END\r\n  {\r\n    $filter = @()\r\n    foreach ($ObjectType in $RefObjecTypes)\r\n    {\r\n        $filter = $filter + \"\/$ObjectType[DisplayName = '$DisplayName']\"\r\n    }\r\n\r\n    $FIMObject = Export-FIMConfig -customConfig ($filter) -OnlyBaseResources\r\n\r\n    if ($FIMObject -eq $null)\r\n    {\r\n        write-host \"No match found for referenced object $DisplayName\"\r\n    }\r\n    elseif ($FIMObject.Count -eq $null)\r\n    {\r\n        $FIMObject.ResourceManagementObject.ObjectIdentifier\r\n    }\r\n    else\r\n    {\r\n        write-host \"Multiple matches found for referenced object $DisplayName\"\r\n    }\r\n  }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I was trying to update a script so it could resolve references to various resource types. I&#8217;d seen in the help that you can do this: Export-FIMConfig -customConfig (&#8220;\/ConstosoCustomResource&#8221;, &#8220;\/Group&#8221;) So in my script I spent ages trying to construct a string like &#8220;(&#8220;\/ConstosoCustomResource&#8221;, &#8220;\/Group&#8221;)&#8221; and then wondering why it wouldn&#8217;t work.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","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,50],"tags":[],"class_list":["post-2066","post","type-post","status-publish","format-standard","hentry","category-fim-2010","category-powershell","category-scripting"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-xk","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2066","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=2066"}],"version-history":[{"count":6,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2066\/revisions"}],"predecessor-version":[{"id":2072,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2066\/revisions\/2072"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=2066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=2066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=2066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}