Well , this could lead to a wider discussion of determinism vs free will , but this is definitely out of scope of the question .
So here is my thoughts on this , remember when Allah said that he would create a new creation to inherit the earth and the angels voiced their concern ?
وَإِذْ قَالَ رَبُّكَ لِلْمَلَائِكَةِ إِنِّي جَاعِلٌ فِي الْأَرْضِ خَلِيفَةً ۖ قَالُوا أَتَجْعَلُ فِيهَا مَن يُفْسِدُ فِيهَا وَيَسْفِكُ الدِّمَاءَ وَنَحْنُ نُسَبِّحُ بِحَمْدِكَ وَنُقَدِّسُ لَكَ ۖ قَالَ إِنِّي أَعْلَمُ مَا لَا تَعْلَمُونَ
And [mention, O Muhammad], when your Lord said to the angels, "Indeed, I will make upon the earth a successive authority." They said, "Will You place upon it one who causes corruption therein and sheds blood, while we declare Your praise and sanctify You?" Allah said, "Indeed, I know that which you do not know."
Notice how Allah said directly to the Angels that the new creation will inherit The earth , and that was before Adam was banished from heaven to Earth , in fact before Adam was created in the first place , so we know that without a shadow of a doubt Allah knew about this whole exchange between Satan and Adam , and that Satan would refuse to prostrate and all the events that would follow that and all the events before that actually , Allah knows everything all the time everywhere and anywhere .
Now This might tempt you to say that Satan shouldn't be punished as he only follows what was ordered of him , here is where the fallacy lies .
Just because Allah knows what will happen doesn't mean he influenced anyone to choose the path they did , infact an analogy I read once about that says that having a time machine and traveling back and forth in time as a spectator isn't equivalent to having any influence on people's free will .
So Allah knows he would do that , he just didn't Influence Satan into doing it.
Thus preserving the freedom of will , which is guaranteed for both Human and Jinn(Satan) .
To answer your question : yes , Allah knew Iblis would do that , but he didn't command him to do it by any means , it was an internal drive from Iblis himself , his own arrogance and self-importance .