FIM2010: How to Run Management Agent via XML Source with PowerShell
The source is an XML file containing the details of Management Agent profile. If there is any change in the sequence of profile Run, the administrator can do the change in XML without modifying the script or code.
The format of XML file
<?xml version="1.0" encoding="utf-8" ?>
<Task name="Daily Cycle">
<step task="run" profile="Full Import" maname="SQL MA"/>
<step task="run" profile="Full Synchronization" maname="SQL MA"/>
</Task>
The Script
001
002 003 004 005 006 007 008 009 010 011 012 013 |
function Runprofile($x,$y)
{ $MaName= "$x" $ProfileName="$y" $curMA = @(get-wmiobject -class "MIIS_ManagementAgent" -namespace "root\MicrosoftIdentityIntegrationServer" -computername "." -filter "Name='$MaName'") $Execution=$($curMA[0].Execute($ProfileName).ReturnValue) } $run=[xml](Get-Content C:\Users\Administrator\Desktop\Profile.xml) # Path of the XML file having the MA profile details $run.Task.ChildNodes|%{ $x=$_.maname $y=$_.Profile Write-Host "Executing the Management Agent $x and $y" Runprofile $x $y } |
References
Configuring a PowerShell Script to Run as a Scheduled Task.