So, if the ends do justify the means, an innocent man could walk into the hospital and be killed for his organs. His organs, after all, could save multiple people who have been waiting for an organ donor. I think that most people, including myself, will argue that that is unjust, and even Machiavelli would likely shudder at that too.
If you're interested in this "ends justifying the means" stuff, you should definitely Wikipedia the Moscow theater hostage situation that occured in 2002, or maybe you remember what happened with that. (Wikipedia can describe it better than me.) It was on the news for days, and I just think that it's a perfect example of where one must wonder whether the ends justify the means. I think that in this case, the ends do justify the means, but it is even hard for me to say that with certainty because plenty of hostages died this way; maybe the Chechens would have let most of the hostages go free in the end ... similar to the Budyonnovsk hospital hostage situation (although plenty of people died in that one too).
I don't think that there is a black & white answer to your question. It probably depends on the situation and how harsh the possible consequences could be.