Hello,
AD users who are inactive in Exchange for a certain amount of time can be disabled using a script executed in a scheduled task. For us to provide you with the script, please, specify whether it should also enable users. If it does, please, describe the entire desired behavior in all the possible details with live examples.