Thursday, April 19, 2018

Saving FIM / MIM configuration

Just a quick note with a small Powershell script that I made to export configuration for the Synchronization Engine. I use this script on and off at customers to make sure that we can get back to a former state - or move existing configuration from environment to environment when building.

Feel free to use and modify

param
(
$miispath = 'C:\Program Files\Microsoft Forefront Identity Manager\2010\Synchronization Service\Bin\',
$extensionspath = 'C:\Program Files\Microsoft Forefront Identity Manager\2010\Synchronization Service\Extensions\',
$maexport = ( join-path $miispath 'maexport.exe' ),
$svrexport = ( join-path $miispath 'svrexport.exe' ),
$exportdir = 'export-config'
)
$date = (get-date).tostring('yyyy-MM-dd')

# create base folders with current date
$madir = join-path (join-path (join-path . $exportdir ) $date) 'ma'
write-debug $madir
$null = new-item -path $madir -type directory -force

$svrdir = join-path (join-path (join-path . $exportdir ) $date) 'svrexport'
write-debug $svrdir
$null = new-item -path $svrdir -type directory -force

$extdir = join-path (join-path (join-path . $exportdir ) $date) 'extensions'
write-debug $extdir
$null = new-item -path $extdir -type directory -force

$managementagents = @(get-wmiobject -class "MIIS_ManagementAgent" -namespace "root\MicrosoftIdentityIntegrationServer" -computername ".") 
if($managementagents -eq 0) {throw "There is no management agent configured"}

foreach ($ma in $managementagents)
{
& $maexport $ma.name (join-path $madir "$($ma.name).xml")
}

copy $extensionspath\*.* $extdir

& $svrexport $svrdir

Thanks,
Soren