Import pictures into FIM portal

#UPDATE 16. April 2013: Changed the PS script to write directly to binary attribute Picture in CS. Removing the need for rules extension. The new updates is uploaded in the zip file. Also remember to update your Schema file (example further down in this post)..
#UPDATE 29. April 2013 – Fixed bug on line 74. From FileDate to FileData.

Søren Granfeldt has done an amazing job creating a Powershell MA for FIM2010. We wanted to use this MA to import user pictures from a fileshare and into the FIM portal. When we got it in the FIM portal it is no problem exporting it to ex. Active Directory.

Our picture filenames was formatted like this: FULLNAME#ACCOUNTNAME.JPG (You can change the filter to your needs in our PowerShell script).

With the help of my good friend and colleague Didier Rossi (who is a master in pretty much everything, include cooking food). We jumped right into it. We`ll show you how we did it.

Prerequisite: As we are using WIA Object trough the Image PS module you have to Add the feature “Desktop experience” and run the “Windows Image Acquisition” Service under Windows Server 2008/R2.

#1 – Download and install the Powershell MA – REMEMBER to donate some to Søren`s great job!

#2 – Download

Remember to unblock the zip files before unzippping.
(Right click>Properties>Unblock content).

#3 – Now. We have to create three files. Export.ps1, Password-ChangeSet.ps1 and Get-Schema.ps1 I placed my files like this, for now. They are all empty files.

#4 – Unzip and copy the Import.ps1 to C:\FIMpowershellCode\AccessCardPictures
Copy the Image folder to: C:\Windows\System32\WindowsPowerShell\v1.0\Modules

#5 – Open up Get-Schema and paste the following:
You can of course change this how you like. Wanna learn more (

# Schema creation in FIM
# Put this commands in a seperate file named schema.ps1 and call it from the Powershell MA.
$obj = New-Object -Type PSCustomObject
$obj | Add-Member -Type NoteProperty -Name "objectClass|String" -Value "user"
$obj | Add-Member -Type NoteProperty -Name "Anchor-AccountName|String" -Value "IAMBLOGG"
$obj | Add-Member -Type NoteProperty -Name "Picture|Binary" -Value 0x10

#6 – Re-open the FIM Synchronization service to get the new ma loaded.

#7 – Create a new MA “Powershell” and give it a nice name 🙂 I named mine “AccessCard Pictures”.

#8 – On the “Connectivity” tab, point to the location where you stored your schema file.
ex. C:\FIMSchemaFiles\AccessCardPictures\Get-Schema.ps1 And give it your fimsync engine service account credentials.

#9 – Global Parameters: Point to your Import, Export and PasswordChange scripts.
We are only using the Import script in this MA, but we had to specify all three. (Not sure why) but I just created two empty files Export.ps1 and Password-ChangeSet.ps1. Use the “Export simple Objects”.

#10 – Configure Partitions and Hierarchies: default

#11 – Select Object Types: user (Depending on what you define in the schema file).

#12 – Select Attributes: AccountName, Picture (I only use these two in this version, change if you changed the schema file).

#13 – Configure Anchors: user AccountName (As my picture filenames include the accountname I use it as anchor).

#14 – Configure Connector Filter: None

#15 – Configure Join and Projection Rules: I made a join rule that joins on AccountName->accountName

#16 – Configure Attribute Flow: Create a new Direct flow rule with
CS attribute [Picture] import to MV attribute [photo]

#17 – Now. You should be able to import images into your metaverse.

Hope it serves you well! Enjoy!

– Remi and Didier

  • Nice work !!! Remember to activate the feature “Desktop experience” on your W2K8 server, else the import script won’t work (the import script uses the powershell module “Image” which uses WIA Object).

    • remv

      Thanks Didier. Post updated 🙂

  • Nice. You should be able to send the binary data directly in – and then you wouldnt need the extension for base64 encoding/decoding.

  • remv

    Thanks Søren! Script and blogpost updated!

  • Vladimir

    Howdy, Remi.

    I’m currently playing with your script and have the following error during the import:

    “Microsoft.MetadirectoryServices.ExtensibleExtensionException: Unable to cast object of type ‘System.Byte[]’ to type ‘System.Object[]’.

    I believe this happens somewhere around

    [byte[]] $b = $image.FileData.BinaryData

    Which is strange, as the $obj looks fine while debugging manually in ISE:

    objectClass user AccountName AGRIGORIEV10186.JPEG Picture {255, 216, 255, 224…}

    It seems that I miss something really simple, but I’m out of ideas what. Could you please give some advice?

    Regards, Vlad

  • Vladimir

    Here we go. That was as simple as old version of PSMA. Had 4.0, solved by 4.5 update (though it requires to re-create MA).

  • Alex

    Hi guys, I run into the following error in step to of configuring the MA.

    “Unable to retrieve schema. Error: An anchor attribute defined by the extension must not be of type Reference or Boolean. A multivalued attribute defined by the extension must not be of type Boolean”

    Where do I go wrong?

  • Remi

    Hello Alex,
    I was a bit quick with my last comment, so I removed it.

    Can you past you schema.ps1 file? It seems like you maybe using a reference or boolean attribute as anchor..

  • Alex

    Hi remi,

    Found a error in my schema file, which I just corrected. Now installed the MA, and working through the picture upload. Have duplication errors during import.
    Thanks for responding.

  • EviljesterNZ

    One thing that tripped me up for a minute or 2, was the “j” missing on line 7 of your “get-schema” sample code above…