Skip to content

Instantly share code, notes, and snippets.

@msidmvp
Created April 5, 2017 15:06
Show Gist options
  • Save msidmvp/80437cf6136784cfb5e276e38b9cc455 to your computer and use it in GitHub Desktop.
Save msidmvp/80437cf6136784cfb5e276e38b9cc455 to your computer and use it in GitHub Desktop.
MIM: How To Check Pending Deletes Before Performing An Export
#####################################################################################################
# Simple PowerShell script to prevent running an export if more than 1000 objects are pending delete
#
# More information on FIM and MIM WMI:
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms697764(v=vs.100).aspx
#
$miisWmiObject = get-WMIObject –class MIIS_ManagementAgent –namespace root/MicrosoftIdentityIntegrationServer –filter "Name='ADMA'"
$exportdeletes = $miiswmiobject.NumExportDelete().returnvalue
if ($exportdeletes > 1000)
{
# Do not run AD Export
Send-MailMessage -From "IDM Alert <alert@your_email_domain.com>" -To "IDM Team <idmteam@your_email_domain.com>" -Subject "AD deletes queued" -Body "More than 1000 deletes are queued for ADMA" -smtpserver mail.your_email_domain.com
}
else
{
Run-MA -maName "ADMA" -runProfile "Export"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment