Washington CNN  — 

The Department of Homeland Security notified states on Friday that hackers targeted their election infrastructure ahead of the 2016 election.

“As part of our ongoing information sharing efforts, today DHS notified the Secretary of State or other chief election officer in each state of any potential targeting we were aware of in their state leading up to the 2016 election,” DHS spokesman Scott McConnell said. “We will continue to keep this information confidential and defer to each state whether it wishes to make it public or not.”

The notification of election officials Friday was first reported by The Associated Press.

McConnell added that DHS had also informed the owners and operators of the election systems when it discovered a potential victim, including ones not run by the individual states.

He noted the importance of keeping all parties informed of potential risks, “while protecting the integrity of investigations and the confidentiality of system owners.”

In the majority of the states, which DHS official Samuel Liles told Congress in June could number as many as 21, the activity mostly included activity like scanning and observing, a DHS official said. However, some states experienced unsuccessful attempts to compromise networks, the official said.

A small number of networks were compromised, but none that involved the tallying of votes.

CNN’s Sophie Tatum contributed to this report.