Ministers are set to gain powers over telecoms companies during national security emergencies.