Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson darrenjrobinson/run.ps1 Secret
Last active Jan 17, 2018

What would you like to do?
Azure Powershell Time Function App to Generate FIM/MIM Documentation
# Username for connection to MIM Service via Function Application Settings
$username = $env:MIMSyncCredUser
# Password for connection to MIM Service via Function Application Settings
$pw = $env:MIMSyncCredPassword
# Credentials password (encrypted)
$keypath = 'D:\home\site\wwwroot\myFunctionApp\keys\MIMSync.key'
$password = $pw | ConvertTo-SecureString -key (Get-Content $keypath)
# Created PS Creds
$credentials = New-Object System.Management.Automation.PSCredential $Username,$password
# Connect to the FIM Sync Server
# Will require an inbound rule for TCP 5786 (or your MIM Sync Firewall) in you Resource Group Network Security Group Config
$options = New-PsSessionOption –SkipCACheck -SkipCNCheck
# Setup scriptblock
$scriptblock = {
# Import LithnetMIISAutomation for MIM Sync Server Config Exports
Import-Module lithnetmiisautomation
$MIMDocumenterPath = "C:\FIMDoco"
$MIMDocumenterScript = '\InvokeDocumenter-Customer.ps1'
$foldername = Get-Date -format dd-MM-yyyy;
$ReportPrefix = "$($MIMDocumenterPath)\Report\Customer_Dev_$($foldername)"
$outputfilepath = "$($MIMDocumenterPath)\Data\Customer\Dev\$($foldername)"
$BackupFolder = New-Item -Path $outputfilepath -Type Directory
# SyncServer Config Export
$SyncServer = New-Item -Path "$outputfilepath\SyncConfig" -Type Directory
# Portal Config Exports
$PortalExport = New-Item -Path "$outputfilepath\ServiceConfig" -Type Directory
# Export Sync Server
Export-MetaverseConfiguration -Path $SyncServer.FullName
# Load FIMAutomation Snapins
add-pssnapin FIMAutomation
# Portal Schema
$portalSchema = Export-FIMConfig -uri http://localhost:5725/ResourceManagementService -schemaConfig -customConfig "/SynchronizationFilter" ;
$portalSchema | ConvertFrom-FIMResource -file "$($PortalExport.Fullname)\Schema.xml"
# Portal Policy
$portalPolicy = Export-FIMConfig -uri http://localhost:5725/ResourceManagementService -policyConfig -portalConfig -MessageSize 9999999 ;
$portalPolicy | ConvertFrom-FIMResource -file "$($PortalExport.Fullname)\Policy.xml"
# Generate Report
invoke-expression -Command "$($MIMDocumenterPath)$($MIMDocumenterScript)"
# Create Report Directory
$Report = New-Item -Path "$outputfilepath\Report" -Type Directory
# Copy the Report to the folder associated with the configs
Copy-Item "$($ReportPrefix)_AppliedTo_MIM-SP1-Base_4.4.1302.0_Consolidated_report.html" "$($outputfilepath)\Report"
# Connect to MIM Sync Server and execute our documentation generation script
$results = Invoke-Command $scriptblock -computer -useSSL -credential $credentials -SessionOption $options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.