FIM ScriptBox Item

Summary

FIM Service configuration migration is a tricky topic, but boils down to two object types:

  • ImportObject
  • ExportObject

The ImportObject is produced by the configuration migration commands as shown below.  Sometimes you just might not want to use the ImportObject as-is, but instead change some of the properties on it.  The changes are stored in a property called Changes.  The script below shows how to remove attributes from the Changes property.

I've seen a lot of people do this by modifying the XML files directly, which is a shame because it completely misses the point of PowerShell which is to use objects instead of parsing/writing files.

Script Code

 
 
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
Add-PSSnapin FimAutomation

 ###

 ### Load the two configurations into variables

 ### The XML files were produced using Export-FimConfig...

 ###

 $oldConfig = ConvertTo-FIMResource -File 'c:\Fim\oldConfig.xml'

 $currentConfig = ConvertTo-FIMResource -File 'c:\Fim\currentConfig.xml'



###

### These are the join rules used in the Join cmdlet

###

 $joinrules = @{

     ObjectTypeDescription            = "Name";

     AttributeTypeDescription         = "Name";

     BindingDescription               = "BoundObjectType BoundAttributeType";

     ConstantSpecifier                = "BoundObjectType BoundAttributeType ConstantValueKey";

     SearchScopeConfiguration         = "DisplayName SearchScopeResultObjectType Order";

     ObjectVisualizationConfiguration = "DisplayName AppliesToCreate AppliesToEdit AppliesToView"

 }



###

### Produce the joins using the FIM cmdlet

### This compares the FIM base config to the corp config

###



### When this fails it will point to an object that caused the barfing

### The script snippet below can dig out the offender for viewing pleasures:

 <# $currentConfig | where {$_.ResourceManagementObject.ObjectIdentifier -eq 'urn:uuid:c2abbfc1-e28f-4670-a0b9-e3e5d9d342fa'} | % {$_.ResourceManagementObject.ResourceManagementAttributes} | ft -autosize #>

 $matches = Join-FIMConfig -source $currentConfig -target $oldConfig -join $joinrules -defaultJoin DisplayName

 

###

### Use the Compare cmdlet to produce the diff

###

$diff = $matches | Compare-FIMConfig



### Show some numbers about the diff (WTFC?)

$diff.Count

Write-Host ($diff | Group-Object ObjectType -NoElement | ft -a | Out-String)



###

### The Set objects contain the 'ExplicitMember' attribute

### and for whatever reason I have decided I don't want to move it to my server

### So this loop removes that attribute from all of the ImportObjects

###

$diff | Where {$_.ObjectType -eq 'Set' -and $_.State -eq 'Put'} | ForEach-Object {

   $_.Changes = $_.Changes | Where {$_.AttributeName -ne 'ExplicitMember'}

 }
 

 

 

 

note Note
To provide feedback about this article, create a post on the FIM TechNet Forum.
For more FIM related Windows PowerShell scripts, see the  FIM ScriptBox

 



See Also