The archdiocese of Milan remained vacant after the death of Cardinal Giovanni Battista Caprara in 1810 because Emperor Napoleon did not allow the appointment of a successor. The diocese was ruled for eight years by the vicar appointed by the Cathedral chapter, Monsignor Carlo Sozzi. This period of vacancy was marked by the Napoleonic Wars, and by the consequences of the anticlerical regulations of the previous years. After the defeat of Napoleon in 1815, the Congress of Vienna assigned Milan to the Kingdom of Lombardy–Venetia ruled by Emperor Francis II. On 1 March 1816 Francis II appointed the Austrian Gaisruck as Archbishop of Milan without the previous agreement of Pope Pius VII. It took about two years of negotiations with Rome to settle the issue, and the appointment of Gaisruck was confirmed by the Pope on 16 March 1818. On 27 September 1824 Gaisruck was promoted Cardinal Priest with the title of San Marco.. After years of difficulty due to the Joseph's and Napoleonic anticlerical reforms, Gaisruck got started with the reform of the clergy: he took a census of all the priests and benefices in the diocese, assigned the empty benefices with open competitive exams, expelled many illiterate foreign priests particularly from Corsica, asked the government to open a penitentiary for priests, and reopened the seminaries. Gaisruck, who was not Italian, ruled the diocese through a council of twelve Italian priests. Gaisruck had a preference for the secular priests formed in the seminaries of the diocese. His approach with the religious orders was complex: he did not allow the return in Milan of the Jesuits, Dominicans and Capuchins, but he allowed for example the Barnabites and the Somaschi, more active in assistance and education. Among the congregations of nuns, he allowed the reconstitution of the Ambrosians of the Sacro Monte and in 1844 the Ursulines. In 1841 he founded the journal L'amico cattolico to promote an updated religious information. Gaisruck was charged by some anonymous priests in front of Pope Gregory XVI of Jansenist leanings and not to be enough a devotee to Rome. The pope himself wrote him a letter of reprimand in regard to the 1844 edition of the AmbrosianBreviary. Gaisruck rejected both charges. Cardinal Gaisruck participated to the 1829 and 1830–31 Papal conclaves. In the 1846 conclave, he was to present the veto of the Emperor of Austria against the election of Cardinal Giovanni Maria Mastai-Ferretti, the Archbishop of Imola, but arrived too late; the latter had already been elected and taken the name Pius IX. He died in Milan on 19 November 1846. He left all his properties to the Archdiocese of Milan and his remains were buried in the South nave of the Cathedral of Milan. Even if Gaisruck was personally deemed as a pious and vigorous pastor, his Austrian nationality and his idea of Church tied with the Austrian Empire made him unpopular during the last years of this life, in a period already marked by expectations for the Italian unification.