In 1809 in the war of the Fifth Coalition against France, Ferdinand commanded an Austrian army of 36,000 men. In April he invaded the Duchy of Warsaw hoping to encourage a local uprising against Napoleon (see Polish–Austrian War). But the Poles rallied to Prince Józef Antoni Poniatowski. Ferdinand was defeated at the Battle of Raszyn, but managed to occupy Warsaw. In June, however, Ferdinand was compelled to withdraw from Warsaw, and to give up Kraków and Galicia as well.