How to Use PowerShell to Create FIM ActivityInformationConfiguration Objects

FIM ScriptBox Item

Summary

FIM 2010 can be extended with custom WF activities.  Try it out using the TechNet guide:

How to: Create a Custom Logging Activity and Deploy it to the FIM Portal

One of the challenges with creating (for me at least) is getting the details of the Activity Information Configuration object correct.

The script below takes the details directly from the WF DLL that you've built.  Just point it to the DLL file and it will figure out the details then create the object in FIM for you.

 

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
###
### Load the FIM Cmdlets
###
if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}

Function Create-FimImportObject
{
PARAM($objectType)
END
{
$newObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
$newObject.ObjectType = $objectType
$newObject.SourceObjectIdentifier = [System.Guid]::NewGuid().ToString()
$newObject
}
}

Function Set-FimAttribute
{
PARAM($object, $attributeName, $attributeValue)
END
{
$importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange
$importChange.Operation = 1
$importChange.AttributeName = $attributeName
$importChange.AttributeValue = $attributeValue
$importChange.FullyResolved = 1
$importChange.Locale = "Invariant"
if ($object.Changes -eq $null) {$object.Changes = (,$importChange)}
else {$object.Changes += $importChange}
}
}

###
### Load the assembly to get the required details
###
Copy file://tsclient/q/Scratch/LoggingActivityLibrary/bin/Debug/LoggingActivityLibrary.dll
$ass = [reflection.Assembly]::LoadFrom("LoggingActivityLibrary.dll")
$TypeName = $ass.GetTypes() | where {$($_.BaseType).Name -ieq 'ActivitySettingsPart'} | select -ExpandProperty FullName
$ActivityName = $ass.GetTypes() | where {$($_.BaseType).Name -ieq 'SequenceActivity'} | select -ExpandProperty FullName
$AssemblyName = $ass.FullName

###
### Create the Activity Information Configuration
###
$fimAIC = Create-FimImportObject -objectType "ActivityInformationConfiguration"
Set-FimAttribute -object $fimAIC -attributeName "DisplayName" -attributeValue $ActivityName
Set-FimAttribute -object $fimAIC -attributeName "Description" -attributeValue $ActivityName
Set-FimAttribute -object $fimAIC -attributeName "ActivityName" -attributeValue $ActivityName
Set-FimAttribute -object $fimAIC -attributeName "AssemblyName" -attributeValue $AssemblyName
Set-FimAttribute -object $fimAIC -attributeName "TypeName" -attributeValue $TypeName
Set-FimAttribute -object $fimAIC -attributeName "IsActionActivity" -attributeValue $true
Set-FimAttribute -object $fimAIC -attributeName "IsAuthenticationActivity" -attributeValue $false
Set-FimAttribute -object $fimAIC -attributeName "IsAuthorizationActivity" -attributeValue $false
Set-FimAttribute -object $fimAIC -attributeName "IsConfigurationType" -attributeValue $true

###
### Send the request to FIM
### !!!This does not require the assembly to be in the GAC!!!
### So don't forget to use gacutil.exe to load it
### Or enjoying troubleshooting THAT issue ;-)
###
$fimAIC | Import-FIMConfig

 

Note

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

 


See Also