There are bans rooted in funding and grants requirements. Its not only about Iranian and energy and aerospace.
ITAR, Export Control and Defense Budget or National Labs funding are limiting most non-US citizens. NATO citizens can be accepted in some cases but really outside of these two category, other scientists will face limitations at some point of their academic career.
During hiring for faculty positions, Departments are very interested to know about the funding prospects of candidates. In Engineering schools I have seen that the nationality and various Export Control and ITAR and unavailability of many federal(but defense or energy related) grants shortens the prospects on candidates and effectively removes them from the pool of candidates.
Some engineering schools among others are dependent on defense-based labs and collaboration and they seem to mention the area of research they are interested which in effect is a signal to save candidates time if they are very focused on defense funding.
As of "ban" I have seen that candidates from certain sanctioned countries can not work on certain topics(energy, nuclear, nano-material and so on), also if you consider the visa processing as a part of hiring that needs to be done by university you can imagine the bans from department of state/homeland/treasury can play a role in university hiring.
All these limitation on funding and visa can flow down to the level of students and can go up to the whole department level. Some professors do not want to get involved in possible complexities or limitation and you see them not accepting certain nationalities. or departments(e.g. aerospace, nuclear) do not accept students from certain countries.
Last, but not least, and aside from funding, sometimes departments care about their alumni being able to work in sectors they are training for in the US, which also will not work out with many nationalities.