Sandberg still held his offices in 1940, when the occupation of Norway by Nazi Germany started. On 25 September 1940, when Josef Terboven assumed full power in the country, Sandberg was named as Minister of Finance.[3] The Norwegian Fascist party Nasjonal Samling had some influence in naming the cabinet ministers, but Sandberg was one of the non-political cabinet members (together with Sigurd Johannessen and Øystein Ravner) as demanded by Reichskommissariat Norwegen.[5] Sandberg was persuaded to join the cabinet, and later supported in daily affairs, by Reichskommissariat since he wanted to limit the cabinet's financial spendings, especially that of the Ministry of the Interior. At the same time Sandberg was not a member of Nasjonal Samling, and was not chosen when Quisling formed his cabinet on 1 February 1942.[6] Instead he became a high-ranking servant in the Ministry of Finance and Customs. He left on a sick leave on 11 March 1943, and lost the position on 15 September.[3]
In 1945, when the Nazis lost the war, Sandberg formally ceased to be bank director and banking association chairman. In reality he had not been active in the latter position since 1940.[3] He was arrested after the war's end, as the victors wanted a legal purge of those involved with the Nazi rule. According to Kjell Fjørtoft he was abused during the summer, by being ordered to carry heavy corpses from a room at Rikshospitalet and put them in coffins.[6] In the actual trial, he was in the court of appeal sentenced to one year of prison for collaboration ("having supported the enemy"), but he was ultimately acquitted in the Supreme Court of Norway.[1][3]