In this paper, we present our Energy Management Systems (EMS) with intelligent anomaly detection techniques that achieve real-time detection of outlier(s), prediction of future fault(s), and extraction and amendment of historical data anomalies. The EMS has adopted advanced outlier detection theories and frameworks to optimize the use of key energy devices such as distributed energy storages with performance tracking and diagnosis mechanisms. Those advanced detection mechanisms have been integrated with our distributed EMS that communicates with one another to handle the current and potential outlier(s), which realizes the resilient operation of energy systems to avoid sudden interruption of operation. As one of the applications of the anomaly detection to energy management with distributed battery optimization, the framework has also been verified in the use case of demand charge (DC) cost reduction where the results based on modified load data by our proposed mechanism demonstrate the precise calculation of battery dis/charging profile, which reduces the cost incurred from the use of electricity in peak-time DC periods.