1 Chronicles 21:
1 Satan rose up against Israel and incited David to take a census of Israel. 2So David said to Joab and the commanders of the troops, “Go and count the Israelites from Beersheba to Dan. Then report back to me so that I may know how many there are.”
3 But Joab replied, “May the Lord multiply his troops a hundred times over. My lord the king, are they not all my lord’s subjects? Why does my lord want to do this? Why should he bring guilt on Israel?”
Joab voiced his objection to the king's order.
4 The king’s word, however, overruled Joab; so Joab left and went throughout Israel and then came back to Jerusalem. 5Joab reported the number of the fighting men to David: In all Israel there were one million one hundred thousand men who could handle a sword, including four hundred and seventy thousand in Judah.
Joab didn't completely obey the order:
6 But Joab did not include Levi and Benjamin in the numbering, because the king’s command was repulsive to him.
The order bothered Joab's conscience as it bothered God.
7 This command was also evil in the sight of God; so he punished Israel.
2 Samuel 11:
14 In the morning David wrote a letter to Joab and sent it by the hand of Uriah. 15 In the letter he wrote, “Set Uriah in the forefront of the hardest fighting, and then draw back from him, that he may be struck down, and die.” 16 And as Joab was besieging the city, he assigned Uriah to the place where he knew there were valiant men. 17 And the men of the city came out and fought with Joab, and some of the servants of David among the people fell. Uriah the Hittite also died
In this case, Joab didn't voice any objection.
Was Joab guilty of Uriah's death in 2 Samuel 11:14-17?
https://en.wikipedia.org/wiki/Superior_orders :
Superior orders, also known as the Nuremberg defense or just following orders, is a plea in a court of law that a person, whether a member of the military, law enforcement, a firefighting force, or the civilian population, should not be considered guilty of committing actions that were ordered by a superior officer or official.
Joab could plea not guilty using the Nuremberg defense.
Was Joab guilty for carring out the census order?
I don't think so because he voiced his conscience.
Was Joab guilty of Uriah's death in 2 Samuel 11:14-17?
I'd think so if the order didn't bother his conscience. Still the greater guilt is upon David.