FIM Codeplex Powershell & smallest Exch database & provision mailbox RRS feed

  • Question

  • Hi,

    So I finally have the FIM codeplex activity working and it is provisioning mailboxes correctly.

    Next, I would like for it to first evaluate exchange & determine which is the smallest db, but how do I pass this $smallExchDB variable (which is the output of the script) to the command 'enable-mailbox -identity domain\username -database '$smallExchDB'

    This is what I have done:

    One Workflow:

      • First function populates [//workflowdata/accountname] with the accountName attribute (this works)
      • Second function runs the 'smallest exchange db' script and the last line is: $workflowdata ['smallestDB'] = $identityofsmallEXDB (which contains the correct details, the script itself works)
      • Third function populates [//workflowdata/smallestDB] with CustomExpression [//workflowdata/smallestDB]
      • Fourth function runs the following: enable-mailbox -Identity adatum\$accountName -database '$smallestDB' - both $accountName and $smallestDB are in the first line under param()

    Should this be working? What steps am I missing?

    The PostProcessingError is similar to what I have seen before: Type 'System.Management.Automation.RunSpaces.RemotingErrorRecord in assembly...

    Its almost as if the $workflowdata ['smallestDB'] wasnt populated correctly?



    • Edited by D Wind Wednesday, October 3, 2012 7:10 AM
    Wednesday, October 3, 2012 6:37 AM


All replies

  • Just make sure the data you are putting in the workflow data is a POCO like a datetime, string, or int. An object that isn't serializable won't be able to be stored as an isolated app domain is created to run the script... I just tested the code itself quickly to make sure the workflow data is flowing back from the app domain and it is, I'll try to verify in my lab that the workflow data works the same when run in FIM, but I'm pretty sure I am using this functionality some where already.

    Wednesday, October 3, 2012 11:35 AM
  • Thanks Adam, for example the output of my script and the value that is stored in the 2nd function's $smallestDB variable is: Mailbox Database 03 - I am assuming its a string.

    • Edited by D Wind Wednesday, October 3, 2012 12:21 PM
    Wednesday, October 3, 2012 11:54 AM
  • I imagine something like this *should* work: $WorkflowData['SmallestDB'] = Get-MailboxDatabase -Status | Sort-Object DatabaseSize | Select-Object -First 1 -ExpandProperty Name
    Wednesday, October 3, 2012 11:58 AM
  • I have a script that does all that I found on

    so at the end of that script the database value is stored in a variable, and I assign it to 'workflowdata'

    here is another thought - which might be easier:

    what if I run the "smallest db" script as a daily scheduled task, and write the db name to a txt file; then in the FIM powershell activity I simply pick up the contents of this txt file and pass it along to the exchange cmdlet (enable-mailbox ...).

    Do you think this would be possible?

    thank you

    Wednesday, October 3, 2012 12:23 PM
  • Sorry, I assumed you were using Exchange 2010. Long as you are doing $WorkflowData['smallestdb'] = $Optimaldb.DataBaseName  after the $Optimaldb = ($MBXDBTable | Sort-Object ActiveMBs | select -first 1) line then you should be good.
    Wednesday, October 3, 2012 12:36 PM
  • Hi,

    I changed my logic a little bit:

    - now run the Smallest Exchange Database script as a daily task, with output to a text file

    - in the powershell activity I read the text file contents into a variable and pass it along to the 'enable-mailbox...' cmdlet

    and it is working :)

    Thanks for all your help Adam !

    • Edited by D Wind Thursday, October 4, 2012 4:49 AM
    Wednesday, October 3, 2012 11:54 PM
  • FYI, I am working on bug fixes and enhancements, and have fixed this bug!
    Friday, October 19, 2012 4:00 PM