In 1805, having risen to the rank of general of division, he took part in the war against Austria. He occupied Venice and the Republic of Ragusa in 1806, was made governor-general of Venice in 1807, took part in the Erfurt negotiations of 1808, was ennobled as a count, and served with the emperor during the Peninsular War in Spain (1808–1809), where he commanded the division that besieged and won Pamplona. He fought under Viceroy Eugène de Beauharnais at the Battle of Raab in the Italian campaign and the subsequent advance to Vienna.