"Trump has the legal authority to determine that its deployment is necessary. For a start, there should be very little legal controversy in the military's employment to defend the border against an unlawful incursion by foreign nationals. The defense of territory and persons, after all, is the primary responsibility of the Department of Defense. But while there are noted precedent exclusions to Posse Comitatus that allow the military to support civilian authorities in matters relating to national disasters and counterterrorism etc., there are other authorities also relevant here — specifically, the provisions under federal law as vested under Title 10, Chapter 13 of the U.S. code. " Washington Examiner
As I have previously written, the Posse Comitatus Act does not apply to use of troops, Regular Army, USMC or National Guard in situations involving defense of the borders of the United States.
The Posse Comitatus Act was the product of the end of military occupation of the former Confederate States of America. When Southern congressmen regained their seats in Washington they insisted on the passage of a law that would prevent future use of federal troops as an occupation army. Their anger over the occupation was such that they also prevented the appropriation of funds for the purpose of paying the commissioned officers of the US Army for two consecutive years in the 1870s.
Defense of the frontier is not enforcement of civil law.
This could easily become a human catastrophe in the event of an attempt on the part of migrants to force their way across the border. In such an event the migrants may push the women and children out in front to screen the men. If they then attack CBP and Border Patrol police the troops supporting the police will probably fire on them. pl