People who don't have the power of the Holy Spirit only have a form of godliness, but deny the power of God; they resist the baptism with the Holy Spirit, the means of this power just like Jannes and Jambres resisted the power of God that Moses operated by.
JLB
In context, that is NOT what it says. Jannes and Jambres were powerful magicians, they did signs and great wonders. They were able to change their staffs into serpents.
11 But Pharaoh also called the wise men and the sorcerers; so the magicians of Egypt, they also did in like manner with their enchantments.
12 For every man threw down his rod, and they became serpents. But Aaron's rod swallowed up their rods. (Exod. 7:11-12 NKJ)
They duplicated God's signs and wonders, turning water into blood (Ex. 7:22), even caused frogs cover the land of Egypt (Ex. 8:5)
So they aren't denying the power to do signs and wonders. What was being denied is revealed in the context, the power to live righteously....they were lovers of themselves, money, boaster, proud, blaphemers, disobedient to parents, unthankful and unholy etc. These fakers, weeds among the wheat did powerful signs and wonders in Christ's name, but He never knew them. They were workers of lawlessness:
22 "Many will say to Me in that day,`Lord, Lord, have we not prophesied in Your name, cast out demons in Your name, and done many wonders in Your name?'
23 "And then I will declare to them,`I never knew you; depart from Me, you who practice lawlessness!'
(Matt. 7:22-23 NKJ)
We can know them by their fruits, not their profession:
15 "Beware of false prophets, who come to you in sheep's clothing, but inwardly they are ravenous wolves.
16 "You will know them by their fruits. Do men gather grapes from thornbushes or figs from thistles?
17 "Even so, every good tree bears good fruit, but a bad tree bears bad fruit.
18 "A good tree cannot bear bad fruit, nor can a bad tree bear good fruit.
19 "Every tree that does not bear good fruit is cut down and thrown into the fire.
20 "Therefore by their fruits you will know them.
(Matt. 7:15-20 NKJ)
They claim to be lovers of God, but their lawlessness proves they are just like the sorcerers Jannes and Jambres, although they seem like religious people, they deny the power to live righteously. Notice Paul ends congratulating Timothy, in contrast to those TARES, he followed apostolic doctrine, the truth in the Bible:
NKJ 2 Timothy 3:1 But know this, that in the last days perilous times will come:
2 For men will be lovers of themselves, lovers of money, boasters, proud, blasphemers, disobedient to parents, unthankful, unholy,
3 unloving, unforgiving, slanderers, without self-control, brutal, despisers of good,
4 traitors, headstrong, haughty, lovers of pleasure rather than lovers of God,
5 having a form of godliness but denying its power. And from such people turn away!
6 For of this sort are those who creep into households and make captives of gullible women loaded down with sins, led away by various lusts,
7 always learning and never able to come to the knowledge of the truth.
8
Now as Jannes and Jambres resisted Moses, so do these also resist the truth: men of corrupt minds, disapproved concerning the faith;
9 but they will progress no further, for their folly will be manifest to all, as theirs also was.
10 But you have carefully followed my doctrine, manner of life, purpose, faith, longsuffering, love, perseverance, (2 Tim. 3:1-10 NKJ)