Rather than post a maelstrom of quotes I'll just say this:
When you shock a person who's alive with a defibrilator what happens? It knocks them out and can kill them by throwing their heartbeat out of whack. And if their heart is stopped? It can shock it back into a functioning state. It's kinda like that, but with an alien artifact of unknown origin capable of creating life from any available material. It's not a plot hole.
And yes, Sam had no knowledge of what the cube sliver in his posession could do until Wheelie said it would wake up Jetfire. It didn't even do that good a job if you saw Jetfire's state after getting a shot of energy from it. Most likely it wouldn't even work on a dead Transformer. There's also the fact that cube sliver was largely "drained" when it's knowlege and power was absorbed by Sam.
Quoting the Fallen: "The Cube's knowledge and power cannot be destroyed, it can only transform."
This is brought up in DotM since one of the known plot points is that
Optimus revives Sentinel Prime with the Matrix, and the Matrix absorbed the power of the Allspark at the end of RotF (though this is pointed out in the novelization, it's still canon).
Edit: I swear, people who criticize this film act like they didn't even try to pay attention to it.