In this paper, distributed energy management of interconnected microgrids, which is stated as a dynamic economic dispatch problem, is studied. Since the distributed approach requires cooperation of all local controllers, when some of them do not comply with the distributed algorithm that is applied to the system, the performance of the system might be compromised. Specifically, it is considered that adversarial agents (microgrids with their controllers) might implement control inputs that are different than the ones obtained from the distributed algorithm. By performing such behavior, these agents might have better performance at the expense of deteriorating the performance of the regular agents. This paper proposes a methodology to deal with this type of adversarial agents such that we can still guarantee that the regular agents can still obtain feasible, though suboptimal, control inputs in the presence of adversarial behaviors. The methodology consists of two steps: (i) the robustification of the underlying optimization problem and (ii) the identification of adversarial agents, which uses hypothesis testing with Bayesian inference and requires to solve a local mixed-integer optimization problem. Furthermore, the proposed methodology also prevents the regular agents to be affected by the adversaries once the adversarial agents are identified. In addition, we also provide a sub-optimality certificate of the proposed methodology.