Tuesday, May 06, 2014

Update a Binary Attribute in the FIM Service

Copied from the FimPowershellModule documentation on CodePlex.

This sample shows how to update a binary attribute in the FIM Service.
The Person object has a binary attribute in the default schema, and it renders nicely in the FIM Portal so acts as a good sample.
The only trick to this sample is loading the image file (a binary file) into a Base64 encoded string. Once you have that string you can easily use it in a FIM Import Change.

 

 

 

###

### Get the photo and Base64 Encode it

###

$bytes = Get-Content -Encoding Byte -Path 'C:\It-Works-On-My-Machine.jpg'

$profilePhoto = [Convert]::ToBase64String($bytes)

 

###

### Update the Person object's Photo attribute

###

New-FimImportObject -ObjectType Person -State Put -AnchorPairs @{AccountName='hoofhearted'} -Changes @{

    Photo = $profilePhoto

} -ApplyNow

 

No comments: