We would likely want to modify the CSV file or simply don’t want risking someone modifying the code or are not sure whether the other person is comfortable in changing the scripts. The Import-Csv is having the name of the Management Agent and run profile, If there is a need of additional MA to be add or change in the sequence of profile Run, we have to do the change in csv file only.

The format of the CSV file

ManagementAgent,Profile

SAPMA,Full Import

Test MA,Full Import

Test MA,Full Sync

The Code

#========================Run Profile==========================

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)

}

Import-Csv C:\Users\Administrator\Desktop\MA.csv |%{

$x=$_.ManagementAgent

$y=$_.Profile

Runprofile $x $y

}

#=============================End===============================