2 Samuel 24:1
And again the anger of Jehovah was kindled against Israel, and he moved David against them, saying, Go, number Israel and Judah. (ASV)
There are two attributes of God that come into play here. God is omniscient so that He knows all things that are currently happening or that will happen (as well as, but not relevant here, that which has happened in the past). God is also omnipotent so that nothing and no one can prevent Him doing that which He wants to do. Consequently, we can say that God ordains all things because He knows beforehand that which will happen and has the power to intervene to prevent or change any outcome. For any outcome, we can conclude that God caused it directly or that He allowed the outcome through other causes. However, since God can intervene to prevent any outcome, He tells us to credit Him for those things that He did not cause because He has the power to intervene in any outcome, and it is His choice not to intervene to prevent any outcome, even those not caused directly by Him.
We can be told that Satan moved David to number Israel. We can still say that God moved David to number Israel because He allowed Satan to have his way with David when He had the power to intervene to prevent that outcome and it was His choice not to do so.
Edit this section to note miscellaneous facts.