How to Use PowerShell to Run Management Agents

FIM ScriptBox Item

Summary

A PowerShell module is available on CodePlex to simplify FIM management (http://fimpowershellmodule.codeplex.com/ ).

This article shows how to use that module to start a management agent in the FIM Synchronization Engine.
Note: This snippet was copied from the FIM PowerShell Module project documentation. There are more samples there, as well as the module source code.

About Start-Management Agent

The Start-ManagementAgent function is a wrapper for the WMI class provided by the Synchronization Service.  It adds value by making the operation more PowerShell'ish with features such as:

  • Tab Completion
  • Help
  • Error Objects for Exception Handling
  • Running as Jobs
  • Pipeline Support

The online help for the function has more examples, but here are few simple ones:

Script Code - Run a Management

PS C:\Start-ManagementAgent FIM Export

 

Output 

RunNumber    ReturnValue     RunProfile     MaName
---------    -----------     ----------     ------
12           success         Export         FIM    

 

Script Code - Run Multiple Management Agents

PS C:\Start-ManagementAgent FIM Export
Start-ManagementAgent FIM Import
Start-ManagementAgent FIM Sync

Output

RunNumber  ReturnValue    RunProfile    MaName
---------  -----------    ----------    ------
13         success        Export        FIM   
14         success        Import        FIM   
15         success        Sync          FIM   

 

Script Code - Run Multiple Management Agents Concurrently and Wait for them to Finish

@(

 ('ADMA 1',    'Import'),

 ('ADMA 2',    'Import'),

 ('ADMA 3',    'Import')

) | Start-ManagementAgent -AsJob | Wait-Job | Receive-Job

Output

RunNumber ReturnValue    RunProfile    MaName
--------- -----------    ----------    ------
10        success        Import        ADMA 1
10        success        Import        ADMA 2
10        success        Import        ADMA 3

 

 

Note

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

 


See Also