White House press secretary Sean Spicer has said US envoys who don't understand why or how President Donald Trump's travel ban keeps America safe should "get with the programme or they can go."

He was responding to reports that hundreds of US diplomats are set to formally criticise President Trump's new immigration restrictions.