The US president's loyal supporter was confirmed in a narrow vote by the Senate to run an agency he has criticised.