posts - 104 , comments - 115 , trackbacks - 0

Coexistence between Exchange forests (without trusts…) -- Part 11: References & Sync Script

· How to license FIM 2010 & MIM 2016
http://social.technet.microsoft.com/wiki/contents/articles/2487.how-to-license-fim-2010-and-mim-2016.aspx

· Global address list synchronization walkthrough:
https://technet.microsoft.com/en-us/library/cc708642(v=ws.10).aspx

 

Scripts

I did not write these scripts myself, found them only on https://social.technet.microsoft.com/Forums/en-US/c7e204be-05b4-40e1-bf95-e0191a76ece3/using-powershell-to-start-run-profiles?forum=ilm2. Going through them, they get the job done and are synchronizing the directories in my lab happily Smile.

Start-sync.ps1

#@author: Lance Hext

#@mail: lhext@h-cp.us

#############################################################################################

# PARAMETERS #

#############################################################################################

# #

# $debug #

# debug on = $true; #

# Debug off = $false; #

# #

#############################################################################################

#

$debug = $false;

#

#############################################################################################

# #

# $SequenceInfo #

# Place some meaningful information for display at the #

# beginning of the squ3nce #

# #

#############################################################################################

#

$SequenceInfo = "Hourly Synchronization Sequence"

#

#############################################################################################

# #

# $params_ComputerName #

# The name of the server running FIM #

# Use "." if running on the PowerShell script on the FIM server #

# #

#############################################################################################

#

$params_ComputerName = "."

#

#############################################################################################

# #

# $params_delayBetweenExecs #

# delay between each execution, in seconds #

# 1 Minute = 60 #

# 10 Minutes = 600 #

# 15 Minutes = 900 #

# 30 Minutes = 1800 #

# 1 Hour = 3600 #

# #

#############################################################################################

#

$params_delayBetweenExecs = 0

#

#############################################################################################

# #

# $params_numOfExecs #

# The number of executions the script will run before terminating #

# 0 for infinite #

# #

#############################################################################################

#

$params_numOfExecs = 1

#

#############################################################################################

# RUN Profile Sequence Section #

# #

# The array below contains the MA run sequence order #

# #

# Format #

# @{ #

# name=""; #

# profilesToRun=@(""); #

# }; #

# #

#############################################################################################

#

## Addition Info :: Author: Ethan Turk

## Change Info 1: Added to set thresholds for maximum number of changes

## which are allowed in a single run step. You can set individual limits

## for add, updates or deletes.

##

## Ex: Add 'addthreshold=100;', 'delthreshold=100;' or 'updthreshold=1000;' to the

## cycle step below.

## See the 'AD MA' Export step below.

##

## Change Info 2: Added ability to set a mandatory sleep for individual

## sync cycle steps instead of a sleep for the whole set of steps.

##

## Ex: Add 'sleep=120;' to the cycle step below.

## See the 'FIM MA' Delta Import step below.

Note: Adapt the below names to match the names of the Synchronization agents created in MIM. The names must match exactly!

$params_runProfilesOrder =

@(

@{

name="UK GALMA - EX2007";

profilesToRun=@("Delta Synchronization");

};

@{

name="US GALMA - Exchange 2010";

profilesToRun=@("Delta Synchronization");

};

@{

name="UK GALMA - EX2007";

profilesToRun=@("Export");

};

@{

name="Us GALMA - Exchange 2010";

profilesToRun=@("Export");

};

@{

name="UK GALMA - EX2007";

profilesToRun=@("Delta Import");

};

@{

name="US GALMA - Exchange 2010";

profilesToRun=@("Delta Import");

};

);

#

#############################################################################################

# EMAIL PARAMETERS #

#############################################################################################

# #

# $UseEmailCreds #

# Directs the PowerShell script to send Using Credentials #

# $true; = Send email with Creds #

# $false; = Send email without Creds #

# #

#############################################################################################

#

$UseEmailCreds = $false;

#

#############################################################################################

# #

# $emailFrom #

# A Well formatted email address for the FIM Server #

# Example "FIMSequencer@xyz.com" #

# #

#############################################################################################

#

$emailFrom = "SentFrom@yourdomain.com"

#

#############################################################################################

# #

# $emailTo #

# A Well formatted email address for Recipient of the email #

# Example "someone@xyz.com" #

# #

#############################################################################################

#

$emailTo = "AdminEmail@yourdomain.com"

#

#############################################################################################

# #

# $emailCC #

# A Well formatted email address for send a Copy of the email to #

# Example "carboncopy@xyz.com" #

# #

#############################################################################################

#

$emailCC = ""

#

#############################################################################################

# #

# $emailCC1 #

# A Well formatted email address for send a Copy of the email to #

# Example "carboncopy@xyz.com" #

# #

#############################################################################################

#

$emailCC1 = ""

#

#############################################################################################

# #

# $smtpServer #

# A FQDN of a mail server #

# Example "mail.xyz.com" #

# #

#############################################################################################

#

$smtpServer = "your SMTP Server"

#

#############################################################################################

# #

# $EmailperMA #

# Directs the PowerShell script to either send an email at the completion #

# of each MA OR generate One email at the end of the sequence run #

# #

# $true; = Send an email for each MA #

# $false; = Send 1 (one) email at the completion on the Sequence #

# #

#############################################################################################

#

$EmailperMA = $false;

#

#############################################################################################

# #

# $EmailOnErrorOnly #

# Directs the PowerShell script to send and email on failues only #

# $true; = Send email only on an MA Sync Failure ie MA.Result <> "success" #

# $false; = Send email when MA finishes #

# #

#############################################################################################

#

$EmailOnErrorOnly = $false;

#

#############################################################################################

# #

# INCLUDE THE PROGRAM #

# #

# Location of the Actual Program. This can be a relative or physical path #

# #

# NOTE the 1st period is required #

# Examples #

# Physical Path #

# .C:\powershell\RunSequencerProg.ps1 #

# Relative Path #

# ..\RunSequencerProg.ps1 #

# #

#############################################################################################

#

.\RunSequencerProg.ps1

 

RunSequencerProg.ps1

#################################################################################################################################

# FIM 2010 Management Agent Runner #

# Author : Lance Hext #

# Mail : lhext@h-cp.us #

# Version : 1.2.3 #

# Information : This PowerShell script executes an array of managements agents supplied form the calling PowerShell #

# script. This PowerShell script utilizes the FIM wmi interface for the execution and statistics #

# gathering. #

# For each Management executed either a single email is generated per management agent #

# or a combined email is generated which will contain all the statistic from the run. #

# The email contains the following information as part on the email body #

# 1: The Management agent name #

# 2: The Management Agent completion status #

# 3: All Connector space statistics #

# 4: All Inbound Metaverse statistics #

# 5: All Export data counts #

# The email contains the following attachments #

# 1: The complete run history xml #

# 2: All inbound synchronization errors #

# 3: All Exported synchronization errors #

# #

# #

# #

#################################################################################################################################

# #

# START OF POWERSHELL SCRIPT #

# #

#################################################################################################################################

# #

# * * * * * * * * * * * D O N O T M O D I F Y B E L O W * * * * * * * * * * * * * #

# __________________________________ #

# #

#################################################################################################################################

#################################################################################################################################

# START OF FUNCTIONS #

#################################################################################################################################

$line = "-----------------------------"

function Write-Output-Banner([string]$msg)

{

Write-Output $line,("- "+$msg),$line

}

#################################################################################################################################

# END OF FUNCTIONS #

#################################################################################################################################

# START OF DATA #

#################################################################################################################################

$MAs = @(get-wmiobject -class "MIIS_ManagementAgent" -namespace "root\MicrosoftIdentityIntegrationServer" -computername $params_ComputerName)

$numOfExecDone = 0

$SendEmails = $true;

#################################################################################################################################

# END OF DATA #

#################################################################################################################################

# START OF PROGRAM #

#################################################################################################################################

Write-Output-Banner($SequenceInfo)

do

{

Write-Output-Banner("Execution #:"+(++$numOfExecDone))

if (!$EmailperMA)

{

$smtp = new-object Net.Mail.SmtpClient($smtpServer)

$smtpmsg = new-object Net.Mail.MailMessage

$smtpmsg.From = $emailFrom

$smtpmsg.To.Add($emailTo)

if ($emailCC)

{

$smtpmsg.Cc.Add($emailCC)

}

if ($emailCC1)

{

$smtpmsg.Cc.Add($emailCC1)

}

$RunStart = Get-Date

$AllRunTimeStart = Get-Date -uformat "%Y%m%d%I%M%S"

$smtpmsg.Subject = "FIM Run Sequence Results Started : " +$RunStart

$smtpbody = "

$smtpbody += "

"

$smtpbody += "

FIM Processing Results"

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email Create Mail Object"

Write-Output ($dbugmsg)

}

$AllRuns = "AllRuns-" + $AllRunTimeStart + ".xml"

$AllImportErrorRuns = "AllRuns-" + $AllRunTimeStart + "-ImportErrors.csv"

$AllExportErrorRuns = "AllRuns-" + $AllRunTimeStart + "-ExportErrors.csv"

}

foreach($MATypeNRun in $params_runProfilesOrder)

{

$found = $false;

$SendEmails = $true;

foreach($MA in $MAS)

{

if(!$found)

{

if($MA.Name.Equals($MATypeNRun.name))

{

$abortnow = $false

$found=$true;

$maname = $MA.Name

Write-Output-Banner("MA Name: "+$MA.Name,"`n- Type: "+$MA.Type)

foreach($profileName in $MATypeNRun.profilesToRun)

{

## Added 01/23/2012 :: Author: Ethan Turk

## Change Info: Added to allow sleeping for individual Sync Cycle

## Steps instead of a sleep which must run for every step.

if($MATypeNRun.sleep -gt 0) {

"Found Sleep. Sleeping for " + $MATypeNRun.sleep + " seconds" | Out-Host

Start-Sleep -Seconds $MATypeNRun.sleep

}

## End Addition

## Added 03/05/2012 :: Author: Ethan Turk

## Change Info: Added to set thresholds for maximum number of changes

## which are allowed in a single run step. You can set individual limits

## for add, updates and deletes.

$abortthreshold = "Threshold Reached on $maname $profileName. Cancelling run cycle..."

if($MATypeNRun.addthreshold) {

$ttype = "Add"

$addstatus = .\FIM_ActionThresholds.ps1 $MA.Name $ttype $MATypeNRun.addthreshold

if($addstatus) {

$abortnow = "$ttype $abortthreshold"

break

}

}

if($MATypeNRun.updthreshold) {

$ttype = "Update"

$updstatus = .\FIM_ActionThresholds.ps1 $MA.Name $ttype $MATypeNRun.updthreshold

if($updstatus) {

$abortnow = "$ttype $abortthreshold"

break

}

}

if($MATypeNRun.delthreshold) {

$ttype = "Delete"

$delstatus = .\FIM_ActionThresholds.ps1 $MA.Name $ttype $MATypeNRun.delthreshold

if($delstatus) {

$abortnow = "$ttype $abortthreshold"

break

}

}

## End Addition

Write-Output ("Run Profile "+$profileName,"`n -> starting")

$RunTimeStart = Get-Date -uformat "%Y%m%d%I%M%S"

$datetimeBefore = Get-Date;

$result = $MA.Execute($profileName);

$datetimeAfter = Get-Date;

$duration = $datetimeAfter - $datetimeBefore;

# Setup SMTP Message

if($EmailperMA)

{

if ($debug)

{

$dbugmsg = "--> DB ---- In Multiple Email Create new Mail Object"

Write-Output ($dbugmsg)

}

$smtp = new-object Net.Mail.SmtpClient($smtpServer)

if ($UseEmailCreds)

{

$smtp.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

}

$smtpmsg = new-object Net.Mail.MailMessage

$smtpmsg.From = $emailFrom

$smtpmsg.To.Add($emailTo)

if ($emailCC)

{

$smtpmsg.Cc.Add($emailCC)

}

$smtpbody = "

$smtpbody += "

"

$smtpbody += "

FIM Processing Results"

#$smtpbody += "

"

$smtpbody += "

Forefront Identity Manager Management Agent Run Results for: " + $MA.Name +"
"

$smtpbody += "

"

$smtpbody += "

"

$smtpmsg.Subject = "FIM Management Agent - " + $MA.Name

if("success".Equals($result.ReturnValue))

{

$msg = "Done. Duration: "+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds

$smtpmsg.Subject += " Processing Success"

$smtpbody += "

"

if ($EmailOnErrorOnly)

{

$SendEmails = $false;

}

}

else

{

$msg = "Done with Error. Duration: "+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds +" - Error: "+$result

$smtpmsg.Subject += " Processing Error"

$smtpbody +="

"

$smtpbody +="

"

}

}

else

{

$smtpbody += "

Forefront Identity Manager Management Agent Run Results
 
 
" + $MA.Name +" Completed Successfully
" + $MA.Name +": Completed.
MA Synchronization Status: " + $result.ReturnValue + "
"

$smtpbody += "

"

$smtpbody += "

"

if("success".Equals($result.ReturnValue))

{

$msg = "Done. Duration: "+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds

$smtpbody += "

"

$smtpbody += "

"

if ($EmailOnErrorOnly)

{

$SendEmails = $false;

}

}

else

{

$msg = "Done with Error. Duration: "+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds +" - Error: "+$result

$smtpbody += "

"

$smtpbody += "

"

}

$SendEmails = $true

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email : New Table "

Write-Output ($dbugmsg)

}

}

# Problems with RunHistory WMI not working with MaGuid or MaName, so I used RunDetails from the MA.

# $RunHistory = get-wmiobject -class "MIIS_RunHistory" -namespace "root\MicrosoftIdentityIntegrationServer" -filter("MaGuid='" + $MA.guid + "'")

# # Write the RunHistory file XML out to a file to then attach to the e-mail, and also set it to a XML attribute.

# $RunHistory[1].RunDetails().ReturnValue | Out-File RunHistory.xml

# Grab the first run-history, which always is the latest result.

# [xml]$RunHistoryXML = $RunHistory[1].RunDetails().ReturnValue

#Take the MA RunDetails RunHistory XML and write to file.

$RunHistFileName = $MA.Name + "-" + $RunTimeStart +"-RunHistory.xml"

$ImportErrorUserFileName = $MA.Name + "-" + $RunTimeStart + "-ImportErrors.csv"

$ExportErrorUserFileName = $MA.Name + "-" + $RunTimeStart + "-ExportErrors.csv"

$MA.RunDetails().ReturnValue | Out-File $RunHistFileName

# Grab the MA run-history and put it into a XML var.

[xml]$RunHistoryXML = $MA.RunDetails().ReturnValue

[xml]$RunHistory1XML = $MA.RunDetails().ReturnValue

# Build User Errors for Exports

$RunHistoryXML."run-history"."run-details"."step-details"."synchronization-errors"."import-error" | select dn,"error-type" | export-csv $ImportErrorUserFileName

$RunHistoryXML."run-history"."run-details"."step-details"."synchronization-errors"."export-error" | select dn,"error-type" | export-csv $ExportErrorUserFileName

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

#################################################################################################################################

# Discovery Counters #

#################################################################################################################################

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/ma-discovery-counters/filtered-deletions")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/ma-discovery-counters/filtered-objects")

$smtpbody += "

"

$smtpbody += "

"

#################################################################################################################################

# Staging Counters #

#################################################################################################################################

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-no-change")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-add")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-update")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-delete")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-delete-add")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-failure")

$smtpbody += "

"

$smtpbody += "

"

#################################################################################################################################

# MV Inbound Counters #

#################################################################################################################################

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-remains")

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-projected-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-projected-no-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-joined-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-joined-no-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-flow-remove-mv")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-delete-leave-mv")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/flow-failure")

$smtpbody += "

"

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-no-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-filtered-leave-mv")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-filtered-remove-mv")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-delete-add-processed")

$smtpbody += "

"

# $mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-projected-remove-mv")

# $smtpbody += "

"

# $mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-joined-remove-mv")

# $smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-add")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-update")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-rename")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-delete")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-delete-add")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-failure")

$smtpbody += "

"

$smtpbody += "

"

#################################################################################################################################

# Outbound Counters #

#################################################################################################################################

$outboundCounters=$RunHistory1XML.SelectNodes("run-history/run-details/step-details/outbound-flow-counters")

foreach($outboundCounter in $outboundCounters)

{

$mvValue = $outboundCounter.ma

if ($debug)

{

Write-Output ($outboundCounter)

Write-Output ($mvValue)

}

$smtpbody += "

"

$mvValue = $outboundCounter.SelectSingleNode("provisioned-add-flow")

$smtpbody += "

"

$mvValue = $outboundCounter.SelectSingleNode("provisioned-disconnect")

$smtpbody += "

"

$mvValue = $outboundCounter.SelectSingleNode("connector-flow")

$smtpbody += "

"

$smtpbody += "

"

}

$smtpbody += "

"

$smtpbody += "

Forefront Identity Manager Management Agent Run Results
 
 
" + $MA.Name +" Completed Successfully
MA Synchronization Status: " + $result.ReturnValue + "
" + $MA.Name +": Completed.
MA Synchronization Status: " + $result.ReturnValue + "
 
 
" + $MA.Name + " Run Statistics
 
MA Run Profile:" + $profileName+"
Start Date & Time:" + $MA.RunStartTime().ReturnValue + "
End Date & Time:" + $MA.RunEndTime().ReturnValue + "
Total Run Time:"+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds + "
 
Connector Space Statistics
Total Connector Space Objects:" + $MA.NumCSObjects().ReturnValue +"
Total Connectors:" + $MA.NumTotalConnectors().ReturnValue +"
Connectors:" + $MA.NumConnectors().ReturnValue +"
Explicit Connectors:" + $MA.NumExplicitConnectors().ReturnValue +"
Total Disconnectors:" + $MA.NumTotalDisconnectors().ReturnValue +"
Disconnectors:" + $MA.NumDisconnectors().ReturnValue +"
Explicit Disconnectors:" + $MA.NumExplicitDisconnectors().ReturnValue +"
Total Placeholders:" + $MA.NumPlaceholders().ReturnValue +"
Total Placeholders:" + $MA.NumPlaceholders().ReturnValue +"
 
Discovoery Statistics
Filtered Deletions" + $mvValue.InnerText +"
Filtered Objects:" + $mvValue.InnerText +"
 
Stage Import Statistics
Import Stage Unchanged:" + $mvValue.InnerText +"
Import Stage Add:" + $mvValue.InnerText +"
Import Stage Updates:" + $mvValue.InnerText +"
Import Stage Deletes:" + $mvValue.InnerText +"
Import Stage Delete-Adds:" + $mvValue.InnerText +"
Import Stage Failures:" + $mvValue.InnerText +"
 
Inbound Statistics
Disconnectors
Filtered Disconnectors:" + $MA.NumFilteredDisconnectors().ReturnValue +"
Disconnectors" + $mvValue.InnerText +"
 
Metaverse
Projections - With Flow Updates:" + $mvValue.InnerText +"
Projections - Without Flow Updates:" + $mvValue.InnerText +"
Joins - With Flow Updates:" + $mvValue.InnerText +"
Joins - Without Flow Updates:" + $mvValue.InnerText +"
Deleted Metaverse Objects" + $mvValue.InnerText +"
Disconnected Metaverse Objects" + $mvValue.InnerText +"
Metaverse Flow Failures" + $mvValue.InnerText +"
Connector Objects
Connector With Flow Updates:" + $mvValue.InnerText +"
Connector Without Flow Updates:" + $mvValue.InnerText +"
Connector Filtered" + $mvValue.InnerText +"
Connector Filtered Deleted" + $mvValue.InnerText +"
Connector Delete-Add" + $mvValue.InnerText +"
Metaverse Disconnectors Projected" + $mvValue.InnerText +"
MV Deleted - Joined Disconnectors" + $mvValue.InnerText +"
 
Export Statistics
Export Adds" + $mvValue.InnerText +"
Export Updates" + $mvValue.InnerText +"
Export Renames" + $mvValue.InnerText +"
Export Deletes" + $mvValue.InnerText +"
Export Delete-Adds" + $mvValue.InnerText +"
Export Failures" + $mvValue.InnerText +"
 
OutBound Statistics for: " + $mvValue + "
Provisioning Adds:" + $mvValue.InnerText +"
Provisioning Disconnect:" + $mvValue.InnerText +"
Export Attribute Flow:" + $mvValue.InnerText +"
 
 
"

# Write-Output ( $smtpbody )

if($EmailperMA)

{

if ($debug)

{

$dbugmsg = "--> DB ---- In Multiple Email Send"

Write-Output ($dbugmsg)

}

$RHFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $RunHistFileName)

$smtpmsg.Attachments.Add($RHFile)

$IUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $ImportErrorUserFileName)

$smtpmsg.Attachments.Add($IUFile)

$EUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $ExportErrorUserFileName)

$smtpmsg.Attachments.Add($EUFile)

$smtpmsg.Body = $smtpbody

$smtpmsg.IsBodyHTML = $true

if ($SendEmails)

{

$smtp.Send($smtpmsg)

}

$RHFile.Dispose()

$IUFile.Dispose()

$EUFile.Dispose()

remove-item $RunHistFileName

remove-item $ImportErrorUserFileName

remove-item $ExportErrorUserFileName

}

else

{

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email Conat files"

Write-Output ($dbugmsg)

}

cat $RunHistFileName > $AllRuns

cat $ImportErrorUserFileName > $AllImportErrorRuns

cat $ExportErrorUserFileName > $AllExportErrorRuns

remove-item $RunHistFileName

remove-item $ImportErrorUserFileName

remove-item $ExportErrorUserFileName

}

Write-Output (" -> "+$msg)

Write-Output (" -> "+$result.ReturnValue)

}

}

}

if($abortnow) { break }

}

if(!$found -and !$abortnow)

{

Write-Output ("Not found MA Name:"+$MATypeNRun.name);

}

}

if($abortnow) { $abortnow | Out-Host }

$continue = ($params_numOfExecs -EQ 0) -OR ($numOfExecDone -lt $params_numOfExecs)

if($continue)

{

Write-Output-Banner("Sleeping "+$params_delayBetweenExecs+" seconds")

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email SLEEP Send"

Write-Output ($dbugmsg)

}

if(!$EmailperMA)

{

$smtpbody = "" + $abortnow +

"

" + $smtpbody

$RHFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllRuns)

$smtpmsg.Attachments.Add($RHFile)

$IUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllImportErrorRuns )

$smtpmsg.Attachments.Add($IUFile)

$EUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllExportErrorRuns )

$smtpmsg.Attachments.Add($EUFile)

$smtpmsg.Body = $smtpbody

$smtpmsg.IsBodyHTML = $true

if ($SendEmails -and $abortnow)

{

$smtp.Send($smtpmsg)

}

$RHFile.Dispose()

$IUFile.Dispose()

$EUFile.Dispose()

remove-item $AllRuns

remove-item $AllImportErrorRuns

remove-item $AllExportErrorRuns

}

Start-Sleep -s $params_delayBetweenExecs

}

else

{

Write-Output ("******************************")

}

}

while($continue)

if(!$EmailperMA)

{

$smtpbody = "" +

$abortnow + "

" + $smtpbody

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email Send"

Write-Output ($dbugmsg)

}

$RHFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllRuns)

$smtpmsg.Attachments.Add($RHFile)

$IUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllImportErrorRuns )

$smtpmsg.Attachments.Add($IUFile)

$EUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllExportErrorRuns )

$smtpmsg.Attachments.Add($EUFile)

$smtpmsg.Body = $smtpbody

$smtpmsg.IsBodyHTML = $true

if ($SendEmails -and $abortnow)

{

$smtp.Send($smtpmsg)

}

$RHFile.Dispose()

$IUFile.Dispose()

$EUFile.Dispose()

remove-item $AllRuns

remove-item $AllImportErrorRuns

remove-item $AllExportErrorRuns

}

 

FIM_ActionThresholds.ps1

#################################################################################################################################

# FIM 2010 Management Agent Runner #

# Author : Lance Hext #

# Mail : lhext@h-cp.us #

# Version : 1.2.3 #

# Information : This Powershell script execcutes an array of managements agents supplied form the calling Powershell #

# script. This powershell script utilizes the FIM wmi interface for the execution and statistics #

# gathering. #

# For each Management executed either a single email is generted per management agent #

# or a combined email is generated which will contain all the statistic from the run. #

# The email containes the following information as part on the email body #

# 1: The Managemenmt agent name #

# 2: The Mnagement Agent complition status #

# 3: All Connector space statistics #

# 4: All Inbound Metaverse statistices #

# 5: All Export data counts #

# The email contains the following attachments #

# 1: The complete run history xml #

# 2: All inbound syncronization errors #

# 3: All Exported syncronization errors #

# #

# #

# #

#################################################################################################################################

# #

# START OF POWERSHELL SCRIPT #

# #

#################################################################################################################################

# #

# * * * * * * * * * * * D O N O T M O D I F Y B E L O W * * * * * * * * * * * * * #

# __________________________________ #

# #

#################################################################################################################################

#################################################################################################################################

# START OF FUNCTIONS #

#################################################################################################################################

$line = "-----------------------------"

function Write-Output-Banner([string]$msg)

{

Write-Output $line,("- "+$msg),$line

}

#################################################################################################################################

# END OF FUNCTIONS #

#################################################################################################################################

# START OF DATA #

#################################################################################################################################

$MAs = @(get-wmiobject -class "MIIS_ManagementAgent" -namespace "root\MicrosoftIdentityIntegrationServer" -computername $params_ComputerName)

$numOfExecDone = 0

$SendEmails = $true;

#################################################################################################################################

# END OF DATA #

#################################################################################################################################

# START OF PROGRAM #

#################################################################################################################################

Write-Output-Banner($SequenceInfo)

do

{

Write-Output-Banner("Execution #:"+(++$numOfExecDone))

if (!$EmailperMA)

{

$smtp = new-object Net.Mail.SmtpClient($smtpServer)

$smtpmsg = new-object Net.Mail.MailMessage

$smtpmsg.From = $emailFrom

$smtpmsg.To.Add($emailTo)

if ($emailCC)

{

$smtpmsg.Cc.Add($emailCC)

}

if ($emailCC1)

{

$smtpmsg.Cc.Add($emailCC1)

}

$RunStart = Get-Date

$AllRunTimeStart = Get-Date -uformat "%Y%m%d%I%M%S"

$smtpmsg.Subject = "FIM Run Sequence Results Started : " +$RunStart

$smtpbody = "

$smtpbody += "

"

$smtpbody += "

FIM Processing Results"

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email Create Mail Object"

Write-Output ($dbugmsg)

}

$AllRuns = "AllRuns-" + $AllRunTimeStart + ".xml"

$AllImportErrorRuns = "AllRuns-" + $AllRunTimeStart + "-ImportErrors.csv"

$AllExportErrorRuns = "AllRuns-" + $AllRunTimeStart + "-ExportErrors.csv"

}

foreach($MATypeNRun in $params_runProfilesOrder)

{

$found = $false;

$SendEmails = $true;

foreach($MA in $MAS)

{

if(!$found)

{

if($MA.Name.Equals($MATypeNRun.name))

{

$abortnow = $false

$found=$true;

$maname = $MA.Name

Write-Output-Banner("MA Name: "+$MA.Name,"`n- Type: "+$MA.Type)

foreach($profileName in $MATypeNRun.profilesToRun)

{

## Added 01/23/2012 :: Author: Ethan Turk

## Change Info: Added to allow sleeping for individual Sync Cycle

## Steps instead of a sleep which must run for every step.

if($MATypeNRun.sleep -gt 0) {

"Found Sleep. Sleeping for " + $MATypeNRun.sleep + " seconds" | Out-Host

Start-Sleep -Seconds $MATypeNRun.sleep

}

## End Addition

## Added 03/05/2012 :: Author: Ethan Turk

## Change Info: Added to set thresholds for maximum number of changes

## which are allowed in a single run step. You can set individual limits

## for add, updates and deletes.

$abortthreshold = "Threshold Reached on $maname $profileName. Cancelling run cycle..."

if($MATypeNRun.addthreshold) {

$ttype = "Add"

$addstatus = .\FIM_ActionThresholds.ps1 $MA.Name $ttype $MATypeNRun.addthreshold

if($addstatus) {

$abortnow = "$ttype $abortthreshold"

break

}

}

if($MATypeNRun.updthreshold) {

$ttype = "Update"

$updstatus = .\FIM_ActionThresholds.ps1 $MA.Name $ttype $MATypeNRun.updthreshold

if($updstatus) {

$abortnow = "$ttype $abortthreshold"

break

}

}

if($MATypeNRun.delthreshold) {

$ttype = "Delete"

$delstatus = .\FIM_ActionThresholds.ps1 $MA.Name $ttype $MATypeNRun.delthreshold

if($delstatus) {

$abortnow = "$ttype $abortthreshold"

break

}

}

## End Addition

Write-Output ("Run Profile "+$profileName,"`n -> starting")

$RunTimeStart = Get-Date -uformat "%Y%m%d%I%M%S"

$datetimeBefore = Get-Date;

$result = $MA.Execute($profileName);

$datetimeAfter = Get-Date;

$duration = $datetimeAfter - $datetimeBefore;

# Setup SMTP Message

if($EmailperMA)

{

if ($debug)

{

$dbugmsg = "--> DB ---- In Multiple Email Create new Mail Object"

Write-Output ($dbugmsg)

}

$smtp = new-object Net.Mail.SmtpClient($smtpServer)

if ($UseEmailCreds)

{

$smtp.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

}

$smtpmsg = new-object Net.Mail.MailMessage

$smtpmsg.From = $emailFrom

$smtpmsg.To.Add($emailTo)

if ($emailCC)

{

$smtpmsg.Cc.Add($emailCC)

}

$smtpbody = "

$smtpbody += "

"

$smtpbody += "

FIM Processing Results"

#$smtpbody += "

"

$smtpbody += "

Forefront Identity Manager Management Agent Run Results for: " + $MA.Name +"
"

$smtpbody += "

"

$smtpbody += "

"

$smtpmsg.Subject = "FIM Management Agent - " + $MA.Name

if("success".Equals($result.ReturnValue))

{

$msg = "Done. Duration: "+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds

$smtpmsg.Subject += " Processing Success"

$smtpbody += "

"

if ($EmailOnErrorOnly)

{

$SendEmails = $false;

}

}

else

{

$msg = "Done with Error. Duration: "+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds +" - Error: "+$result

$smtpmsg.Subject += " Processing Error"

$smtpbody +="

"

$smtpbody +="

"

}

}

else

{

$smtpbody += "

Forefront Identity Manager Management Agent Run Results
 
 
" + $MA.Name +" Completed Successfully
" + $MA.Name +": Completed.
MA Synchronization Status: " + $result.ReturnValue + "
"

$smtpbody += "

"

$smtpbody += "

"

if("success".Equals($result.ReturnValue))

{

$msg = "Done. Duration: "+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds

$smtpbody += "

"

$smtpbody += "

"

if ($EmailOnErrorOnly)

{

$SendEmails = $false;

}

}

else

{

$msg = "Done with Error. Duration: "+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds +" - Error: "+$result

$smtpbody += "

"

$smtpbody += "

"

}

$SendEmails = $true

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email : New Table "

Write-Output ($dbugmsg)

}

}

# Problems with RunHistory WMI not working with MaGuid or MaName, so I used RunDetails from the MA.

# $RunHistory = get-wmiobject -class "MIIS_RunHistory" -namespace "root\MicrosoftIdentityIntegrationServer" -filter("MaGuid='" + $MA.guid + "'")

# # Write the RunHistory file XML out to a file to then attach to the e-mail, and also set it to a XML attribute.

# $RunHistory[1].RunDetails().ReturnValue | Out-File RunHistory.xml

# Grab the first run-history, which always is the latest result.

# [xml]$RunHistoryXML = $RunHistory[1].RunDetails().ReturnValue

#Take the MA RunDetails RunHistory XML and write to file.

$RunHistFileName = $MA.Name + "-" + $RunTimeStart +"-RunHistory.xml"

$ImportErrorUserFileName = $MA.Name + "-" + $RunTimeStart + "-ImportErrors.csv"

$ExportErrorUserFileName = $MA.Name + "-" + $RunTimeStart + "-ExportErrors.csv"

$MA.RunDetails().ReturnValue | Out-File $RunHistFileName

# Grab the MA run-history and put it into a XML var.

[xml]$RunHistoryXML = $MA.RunDetails().ReturnValue

[xml]$RunHistory1XML = $MA.RunDetails().ReturnValue

# Build User Errors for Exports

$RunHistoryXML."run-history"."run-details"."step-details"."synchronization-errors"."import-error" | select dn,"error-type" | export-csv $ImportErrorUserFileName

$RunHistoryXML."run-history"."run-details"."step-details"."synchronization-errors"."export-error" | select dn,"error-type" | export-csv $ExportErrorUserFileName

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

#################################################################################################################################

# Discovery Counters #

#################################################################################################################################

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/ma-discovery-counters/filtered-deletions")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/ma-discovery-counters/filtered-objects")

$smtpbody += "

"

$smtpbody += "

"

#################################################################################################################################

# Staging Counters #

#################################################################################################################################

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-no-change")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-add")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-update")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-delete")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-delete-add")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/staging-counters/stage-failure")

$smtpbody += "

"

$smtpbody += "

"

#################################################################################################################################

# MV Inbound Counters #

#################################################################################################################################

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-remains")

$smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-projected-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-projected-no-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-joined-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-joined-no-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-flow-remove-mv")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-delete-leave-mv")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/flow-failure")

$smtpbody += "

"

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-no-flow")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-filtered-leave-mv")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-filtered-remove-mv")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/connector-delete-add-processed")

$smtpbody += "

"

# $mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-projected-remove-mv")

# $smtpbody += "

"

# $mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/inbound-flow-counters/disconnector-joined-remove-mv")

# $smtpbody += "

"

$smtpbody += "

"

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-add")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-update")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-rename")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-delete")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-delete-add")

$smtpbody += "

"

$mvValue = $RunHistory1XML.SelectSingleNode("run-history/run-details/step-details/export-counters/export-failure")

$smtpbody += "

"

$smtpbody += "

"

#################################################################################################################################

# Outbound Counters #

#################################################################################################################################

$outboundCounters=$RunHistory1XML.SelectNodes("run-history/run-details/step-details/outbound-flow-counters")

foreach($outboundCounter in $outboundCounters)

{

$mvValue = $outboundCounter.ma

if ($debug)

{

Write-Output ($outboundCounter)

Write-Output ($mvValue)

}

$smtpbody += "

"

$mvValue = $outboundCounter.SelectSingleNode("provisioned-add-flow")

$smtpbody += "

"

$mvValue = $outboundCounter.SelectSingleNode("provisioned-disconnect")

$smtpbody += "

"

$mvValue = $outboundCounter.SelectSingleNode("connector-flow")

$smtpbody += "

"

$smtpbody += "

"

}

$smtpbody += "

"

$smtpbody += "

Forefront Identity Manager Management Agent Run Results
 
 
" + $MA.Name +" Completed Successfully
MA Synchronization Status: " + $result.ReturnValue + "
" + $MA.Name +": Completed.
MA Synchronization Status: " + $result.ReturnValue + "
 
 
" + $MA.Name + " Run Statistics
 
MA Run Profile:" + $profileName+"
Start Date & Time:" + $MA.RunStartTime().ReturnValue + "
End Date & Time:" + $MA.RunEndTime().ReturnValue + "
Total Run Time:"+$duration.Hours+":"+$duration.Minutes+":"+$duration.Seconds + "
 
Connector Space Statistics
Total Connector Space Objects:" + $MA.NumCSObjects().ReturnValue +"
Total Connectors:" + $MA.NumTotalConnectors().ReturnValue +"
Connectors:" + $MA.NumConnectors().ReturnValue +"
Explicit Connectors:" + $MA.NumExplicitConnectors().ReturnValue +"
Total Disconnectors:" + $MA.NumTotalDisconnectors().ReturnValue +"
Disconnectors:" + $MA.NumDisconnectors().ReturnValue +"
Explicit Disconnectors:" + $MA.NumExplicitDisconnectors().ReturnValue +"
Total Placeholders:" + $MA.NumPlaceholders().ReturnValue +"
Total Placeholders:" + $MA.NumPlaceholders().ReturnValue +"
 
Discovoery Statistics
Filtered Deletions" + $mvValue.InnerText +"
Filtered Objects:" + $mvValue.InnerText +"
 
Stage Import Statistics
Import Stage Unchanged:" + $mvValue.InnerText +"
Import Stage Add:" + $mvValue.InnerText +"
Import Stage Updates:" + $mvValue.InnerText +"
Import Stage Deletes:" + $mvValue.InnerText +"
Import Stage Delete-Adds:" + $mvValue.InnerText +"
Import Stage Failures:" + $mvValue.InnerText +"
 
Inbound Statistics
Disconnectors
Filtered Disconnectors:" + $MA.NumFilteredDisconnectors().ReturnValue +"
Disconnectors" + $mvValue.InnerText +"
 
Metaverse
Projections - With Flow Updates:" + $mvValue.InnerText +"
Projections - Without Flow Updates:" + $mvValue.InnerText +"
Joins - With Flow Updates:" + $mvValue.InnerText +"
Joins - Without Flow Updates:" + $mvValue.InnerText +"
Deleted Metaverse Objects" + $mvValue.InnerText +"
Disconnected Metaverse Objects" + $mvValue.InnerText +"
Metaverse Flow Failures" + $mvValue.InnerText +"
Connector Objects
Connector With Flow Updates:" + $mvValue.InnerText +"
Connector Without Flow Updates:" + $mvValue.InnerText +"
Connector Filtered" + $mvValue.InnerText +"
Connector Filtered Deleted" + $mvValue.InnerText +"
Connector Delete-Add" + $mvValue.InnerText +"
Metaverse Disconnectors Projected" + $mvValue.InnerText +"
MV Deleted - Joined Disconnectors" + $mvValue.InnerText +"
 
Export Statistics
Export Adds" + $mvValue.InnerText +"
Export Updates" + $mvValue.InnerText +"
Export Renames" + $mvValue.InnerText +"
Export Deletes" + $mvValue.InnerText +"
Export Delete-Adds" + $mvValue.InnerText +"
Export Failures" + $mvValue.InnerText +"
 
OutBound Statistics for: " + $mvValue + "
Provisioning Adds:" + $mvValue.InnerText +"
Provisioning Disconnect:" + $mvValue.InnerText +"
Export Attribute Flow:" + $mvValue.InnerText +"
 
 
"

# Write-Output ( $smtpbody )

if($EmailperMA)

{

if ($debug)

{

$dbugmsg = "--> DB ---- In Multiple Email Send"

Write-Output ($dbugmsg)

}

$RHFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $RunHistFileName)

$smtpmsg.Attachments.Add($RHFile)

$IUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $ImportErrorUserFileName)

$smtpmsg.Attachments.Add($IUFile)

$EUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $ExportErrorUserFileName)

$smtpmsg.Attachments.Add($EUFile)

$smtpmsg.Body = $smtpbody

$smtpmsg.IsBodyHTML = $true

if ($SendEmails)

{

$smtp.Send($smtpmsg)

}

$RHFile.Dispose()

$IUFile.Dispose()

$EUFile.Dispose()

remove-item $RunHistFileName

remove-item $ImportErrorUserFileName

remove-item $ExportErrorUserFileName

}

else

{

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email Conat files"

Write-Output ($dbugmsg)

}

cat $RunHistFileName > $AllRuns

cat $ImportErrorUserFileName > $AllImportErrorRuns

cat $ExportErrorUserFileName > $AllExportErrorRuns

remove-item $RunHistFileName

remove-item $ImportErrorUserFileName

remove-item $ExportErrorUserFileName

}

Write-Output (" -> "+$msg)

Write-Output (" -> "+$result.ReturnValue)

}

}

}

if($abortnow) { break }

}

if(!$found -and !$abortnow)

{

Write-Output ("Not found MA Name:"+$MATypeNRun.name);

}

}

if($abortnow) { $abortnow | Out-Host }

$continue = ($params_numOfExecs -EQ 0) -OR ($numOfExecDone -lt $params_numOfExecs)

if($continue)

{

Write-Output-Banner("Sleeping "+$params_delayBetweenExecs+" seconds")

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email SLEEP Send"

Write-Output ($dbugmsg)

}

if(!$EmailperMA)

{

$smtpbody = "" + $abortnow +

"

" + $smtpbody

$RHFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllRuns)

$smtpmsg.Attachments.Add($RHFile)

$IUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllImportErrorRuns )

$smtpmsg.Attachments.Add($IUFile)

$EUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllExportErrorRuns )

$smtpmsg.Attachments.Add($EUFile)

$smtpmsg.Body = $smtpbody

$smtpmsg.IsBodyHTML = $true

if ($SendEmails -and $abortnow)

{

$smtp.Send($smtpmsg)

}

$RHFile.Dispose()

$IUFile.Dispose()

$EUFile.Dispose()

remove-item $AllRuns

remove-item $AllImportErrorRuns

remove-item $AllExportErrorRuns

}

Start-Sleep -s $params_delayBetweenExecs

}

else

{

Write-Output ("******************************")

}

}

while($continue)

if(!$EmailperMA)

{

$smtpbody = "" +

$abortnow + "

" + $smtpbody

if ($debug)

{

$dbugmsg = "--> DB ---- In Single Email Send"

Write-Output ($dbugmsg)

}

$RHFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllRuns)

$smtpmsg.Attachments.Add($RHFile)

$IUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllImportErrorRuns )

$smtpmsg.Attachments.Add($IUFile)

$EUFile = new-object Net.Mail.Attachment([string](get-location)+'\'+ $AllExportErrorRuns )

$smtpmsg.Attachments.Add($EUFile)

$smtpmsg.Body = $smtpbody

$smtpmsg.IsBodyHTML = $true

if ($SendEmails -and $abortnow)

{

$smtp.Send($smtpmsg)

}

$RHFile.Dispose()

$IUFile.Dispose()

$EUFile.Dispose()

remove-item $AllRuns

remove-item $AllImportErrorRuns

remove-item $AllExportErrorRuns

}

ArrowGreen Coexistence between Exchange forests (without trusts…)  -- Part 10: Configuring Free/Busy
   

Print | posted on Monday, October 19, 2015 11:06 AM | Filed Under [ Exchange Build Guides Deployment ]

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: