Working with the output from Export-FimConfig is not always fun because you have to dig hard to get attributes off an object.
This function I just whipped up will convert a FIM ExportObject to a PowerShell PSObject. The advantage here is that you can then use dot-notation <sp?> to dig out the attributes.
For example the Export-FimConfig used like this produces the output below.
| 001
| Export-FIMConfig -CustomConfig "/Person[AccountName='hi']" |
Source : http://localhost:5725/ResourceManagementService
ResourceManagementObject : Microsoft.ResourceManagement.Automation.ObjectModel.ResourceManagementObject
Source : http://localhost:5725/ResourceManagementService
ResourceManagementObject : Microsoft.ResourceManagement.Automation.ObjectModel.ResourceManagementObject
Now using the fancy new function we get:
| 001
| Export-FIMConfig -CustomConfig "/Person[AccountName='hi']" | Convert-FimExportToPSObject |
ObjectID : urn:uuid:caf0178b-b8c1-41b2-bd71-f2f48b1fdf3b
AccountName : HI
CreatedTime : 7/8/2011 6:02:50 AM
Creator : urn:uuid:7fb2b853-24f0-4498-9534-4e10589723c4
DisplayName : HoofHearted IceMelted
Domain : africa
FirstName : HoofHearted
IsRASEnabled : True
JobTitle : Sheller
LastName : IceMelted
MailNickname : HI
ObjectType : Person
In addition, it is easier to get at the attributes for each object:
| 001 002 003 004
| $person = Export-FIMConfig -CustomConfig "/Person[AccountName='hi']" | Convert-FimExportToPSObject $person.DisplayName $person.AccountName |
HoofHearted IceMelted
HI
Finally, here is the function:
| 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
| Function Convert-FimExportToPSObject { Param ( [parameter(Mandatory=$true, ValueFromPipeline = $true)] [Microsoft.ResourceManagement.Automation.ObjectModel.ExportObject] $ExportObject ) Process { $psObject = New-Object PSObject $ExportObject.ResourceManagementObject.ResourceManagementAttributes | ForEach-Object{ if ($_.Value -ne $null) { $value = $_.Value } elseif($_.Values -ne $null) { $value = $_.Values } else { $value = $null } $psObject | Add-Member -MemberType NoteProperty -Name $_.AttributeName -Value $value } Write-Output $psObject } } |