As the start of the G-20 summit came closer, it became clear that President Donald Trump was about to walk into a hostile zone in Hamburg.
So what did Trump do when he was facing something akin to what an unpopular kid in high school has to deal with when the only empty seat in the cafeteria at lunch time is at the "cool kids" table?
Just to continue the high school analogy, he threw a really good pep rally.
I say "was facing" because his speech in Warsaw Thursday morning already went a long way to achieving the goals Trump needed to achieve at this summit. Obviously a lot can happen between now and when the summit wraps up Saturday, but consider these key "to do list" items he faced well before the day began and how he handled them:
1) Make North Korea the top story and project strength
There's nothing like a very real nuclear threat from a dictator successfully testing ICBM's to get the world's attention. Kim Jong Un's actions over the July 4th holiday ensured that. But President Trump grabbed the opportunity with both hands to rally the world's resolve against North Korea in his Warsaw speech: "This continent no longer confronts the specter of communism," he said. But today … there are dire threats to our security and to our way of life … We will confront them. We will win."
Then he expanded that message of strength in the face of military threats to the war on terror and promised the crowd never to show any weakness.
2) Declare victory... on something
The anti-Trump narrative in Europe and the United States centers around the idea that he is too unpopular and bogged down in scandals to be effective. But speaking about North Korea in Warsaw helped Trump segue neatly to discussing NATO obligations, something that was sure to delight the Polish crowd since the Poles are one of the NATO countries that has been meeting agreed upon defense spending levels. That allowed him to declare a victory of sorts as some major NATO players including Germany have promised to increase their defense spending since Trump made it a public issue during and after the U.S. presidential election.
There are other issues where Trump can conceivably prove he's an effective leader. One is actually on trade where a new study by Britain's Global Trade Alert group finds that U.S. trading partners are taking fewer protectionist actions against America since President Trump took office. Another is the fact that it appears more countries heard Trump's criticisms of the Paris climate agreement and are showing signs of possibly joining the U.S. in backing out of it.
But focusing on defense is much easier to grasp than academic trade studies and possible climate deal changes. Defense is Trump's strong suit right now and his Warsaw speech shows that he knows it.
3) Find a friend
Poland is not one of the G-20 nations. But by praising and standing with the Poles, who are caught in the middle of bullying from Russia and indifference from much of the Western European powers, President Trump made it clear that he's presenting a different and better option. Earlier in the day, he touted the first U.S deal to sell liquefied natural gas to the Poles, which could go a long way toward helping Poland get out from under Russia's heating oil dominance in the region. Trump gave special mention in his speech of the sale of the U.S. Patriot missile defense system to the Poles, which also sends a message to possible Russian military aggression.
All of this could foreshadow an attempt by Trump to achieve highly visible partnerships with actual G-20 members Japan and South Korea as the North Korea threat to those countries in particular reaches crisis levels. If Merkel, new French President Emmanuel Macron, and even Russian President Vladimir Putin and Chinese President Xi Jinping give him the cold shoulder, Trump can and should use the new threats from Pyongyang to present a very visibly warm relationship with Japanese Prime Minister Shinzo Abe and South Korean President Moon Jae-in.
Again, defense and the very serious need for it in light of the North Korean situation steals the show and allows Trump to rise above and beyond other issues that seem naturally small compared to nuclear conflict.
4) Show strength on Russia
So many of Trump's domestic critics continue to obsess over the alleged Russian connections to his campaign and even his extended family. That makes his first private meeting with Putin during this summit crucial to helping reshape that narrative and relieve political pressure on his administration. President Trump must appear independent and strong, but also not too combative and aggressive.
Speaking in front of a very supportive and pro-U.S. crowd in Warsaw Thursday went a long way to accomplishing that goal, and Trump didn't even have to mention Putin's name. Poland has challenged Putin's military and economic goals for years now and is often on the front lines in the face of Moscow's aggressive behavior. Thursday's speech from Trump was certainly not on the same level of John F. Kennedy's "Ich Bin ein Berliner" speech or Ronald Reagan's "Mr. Gorbachev, tear down this wall!" address, but it offered a similar kind of American support for Poland in the face of the Russian bear. It's hard to believe the speech's writers weren't thinking of that similarity when they crafted the address.
Perhaps the message of that speech gave President Trump the preparation he needs to appear sufficiently independent and on the side of the "good guys" compared to Putin and Russia.
None of Trump's most entrenched opponents here and abroad are likely to change their tune about his administration after the summit. But if he sticks to some of the powerful themes he touched on in Warsaw Thursday, a foreign trip that looked like a no-win situation could easily turn into a positive overall.
Commentary by Jake Novak, CNBC.com senior columnist. Follow him on Twitter @jakejakeny.
For more insight from CNBC contributors, follow @CNBCopinion on Twitter.