{"id":2716,"date":"2013-10-04T00:11:06","date_gmt":"2013-10-04T00:11:06","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=2716"},"modified":"2013-10-04T01:41:19","modified_gmt":"2013-10-04T01:41:19","slug":"add-a-filter-to-all-group-criteria","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/add-a-filter-to-all-group-criteria","title":{"rendered":"Add a filter to all Group criteria"},"content":{"rendered":"<p>Some FIM really REALLY annoys me, mostly when I come up against odd and unexpected limitations, but then I write a quick little PowerShell script to fix something or other and remember that this is really one of the best differentiators of the product. This quick fix came about because I realised that the group filters did not consistently use EmployeeStatus as a criterion, and with hundreds and hundreds of groups, there&#8217;s no way they could have been fixed manually.<\/p>\n<p><!--more--><\/p>\n<pre>. E:\\scripts\\FIMPowershell.ps1 #See http:\/\/technet.microsoft.com\/en-us\/library\/ff720152(v=ws.10).aspx\r\n\r\n$filter = \"\/Group\"\r\n$objs = Export-FIMConfig -OnlyBaseResources -CustomConfig $filter\r\n\r\nforeach ($obj in $objs)\r\n{\r\n    $grpfilter = ($obj.ResourceManagementObject.ResourceManagementAttributes | where {$_.AttributeName -eq \"Filter\"}).Value\r\n    $DisplayName = ($obj.ResourceManagementObject.ResourceManagementAttributes | where {$_.AttributeName -eq \"DisplayName\"}).Value\r\n    $DisplayName\r\n\r\n    if ($grpfilter)\r\n    {\r\n        if ($grpfilter.contains(\"EmployeeStatus = 'Active'\")) \r\n        {\r\n            \"Skip\"\r\n        }\r\n        elseif ($grpfilter.contains(\"not(EmployeeStatus = 'Inactive')\")) \r\n        {\r\n            \"Change Inactive to Active\"\r\n            $grpfilter = $grpfilter.Replace(\"not(EmployeeStatus = 'Inactive')\",\"EmployeeStatus = 'Active'\")\r\n            $ImportObject = ModifyImportObject -TargetIdentifier $obj.ResourceManagementObject.ObjectIdentifier -ObjectType \"Group\"\r\n            SetSingleValue $ImportObject \"Filter\" $grpfilter\r\n            $ImportObject | import-fimconfig\r\n        }\r\n        else\r\n        {\r\n            \"Add filter\"\r\n            $grpfilter = $grpfilter.Replace(\"]&lt;\/Filter&gt;\",\" and (EmployeeStatus = 'Active')]&lt;\/Filter&gt;\")\r\n            $ImportObject = ModifyImportObject -TargetIdentifier $obj.ResourceManagementObject.ObjectIdentifier -ObjectType \"Group\"\r\n            SetSingleValue $ImportObject \"Filter\" $grpfilter\r\n            $ImportObject | import-fimconfig\r\n        }\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some FIM really REALLY annoys me, mostly when I come up against odd and unexpected limitations, but then I write a quick little PowerShell script to fix something or other and remember that this is really one of the best differentiators of the product. This quick fix came about because I realised that the group&#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,23],"tags":[],"class_list":["post-2716","post","type-post","status-publish","format-standard","hentry","category-fim-2010","category-fim-2010-r2","category-powershell"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-HO","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2716","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=2716"}],"version-history":[{"count":3,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2716\/revisions"}],"predecessor-version":[{"id":2719,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2716\/revisions\/2719"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=2716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=2716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=2716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}