Spoiler: Wall of text incoming, TL;DR provided.
Once upon a time there were two worlds, separated by some kind of dimensional veil. One world is populated by WW2 level industrial civilization, the other is a fantasy world, inhabited by powerful wizards. At some point the Veil dissipated, and the two worlds merged into one. These two civilizations waged war on each other almost immediately.
The fantasy civilization is a feudal theocracy, ruled by the most powerful mages. When it comes to warfare, fantasy-landers almost always resort to illusion and mind control magic. When mages fight, they try to "hack" the enemy's brain in order to control or kill them. Simultaneously, they weave protective spells in order to prevent mind possession. There is also a type of stealth wizards as well, who specialize in illusion spells, that work like a perception filter.
All mages can be roughly divided into three levels, according to their power.
- Level 3 mages are the weakest and usually don't get involved in wars, being employed as farmers, artisans and etc.
- Level 2 mages form the backbone of magic armies. In terms of power, they pose as much threat as infantry with rifles, capable of casting various spells within ~500 meters radius. However, they can only "hack" visual targets (in other words, one can just hide from them behind some cover).
- Every Level 1 wizard is basically an one-person army. These mages boast a huge ~10-20 km spellcasting radius, as well as having the ability to perceive the world in a "magic spectrum" - which means, anyone who isn't a powerful sorcerer or a Blank* (see below) can't hide or defend themselves from such wizards, as no physical barriers can protect you from their spells. If they must, they can also cast powerful AoE elemental curses that destroy everything in a wide range area. Naturally, these wizards are rarest and make up ~1-2 percent of fantasy-landers' armies.
Most powerful mages are also capable of teleporting themselves (and only themselves, they can't carry much cargo with them or transport others in such fashion) within the abovementioned ~10-20 km range. All magic combatants are taught how to communicate remotely with each through magical means.
However, it takes at least five years to train a Level-2 wizard, while even talented apprentices have to spend decades to become Level-1 wizards. This means that fantasy-landers can't field a large army by modern standards. Though wizards are outnumbered by muggles (~10 to 1), the latters have no means of magical protection. In other words, even an apprentice mage can hack muggle's mind momentarily in order, for example, to turn the possessed soldiers against their comrades.
Plus, many mages have an ability to feel when they're being watched, irregardless of distance. That means, trying to use snipers against enemy's officers would only result in alerting the entire camp, before a sniper makes a shot. Thanks to this, battlemages can also tell where the enemy is aiming - the sorcerers use this ability to dodge the incoming fire.
So far I have come up with a few tactics that muggles might use against mages.
- Trying to take enemy combatants out with artillery/aviation from afar AKA "More Dakka"
While it probably wouldn't be that effective against Level-1 mages, muggles could just bring lots of big guns to the battlefield and suppress the enemy with superior firepower. Even telepathy can't help you to dodge a massive rain of bullets, missiles and shells.
- Recruiting and deploying the so called Blanks.
Among the muggles there is a rare genetic condition, which, besides other symptoms, grants the subjects a complete immunity to magic. Blanks are impervious to mind-control, can see through any illusions, and can't be detected through magic vision. Though, one can still hurt them with magic indirectly (for example, throwing objects at them with telekinesis and etc.).
In particular, mages can't register their presence in aura or feel their gaze, so Blanks would make excellent snipers when it comes to fighting wizards. Plus, they would make a perfect counter against stealth illusionists. However, this condition is incredibly rare, which means that finding and recruiting Blanks would be an issue.
- Getting the collaborating mages to teach the soldiers how to defend against hostile spells.
Some mages will desert to the muggles eventually for various reasons - and offer their skills and knowledge. Though one can't become a proper battlemage in a short period of time, even novices can weave some protective incantations, that might buy you some time, before a mind spell gets you. In a nutshell, such protection serves as a magic equivalent of bulletproof vest. Though it still won't save soldiers from the most powerful mages.
So far I have come up only with a few ideas on how muggle officers would respond to such scenario.
In short:
TL;DR: What can WW2 army do against HarryPotter-esque wizards who are willing to cast Imperius at every opportunity?
P.S. Neither of the warring parties possess nukes or their equivalents.
P.P.S. Because of strict religious taboos, the wizards aren't going to use any of muggle tech.
Edit: Concerning Level 2 mages. The spellweaving process involves inputting a sophisticated coordinate system, i.e. "telling" a spell where it should strike. When a mage sees the target (even if they wear a thick armor and an impenetrable gasmask), it is much easier to send a spell at the right coordinates. It is still possible to try and attack someone behind a wall or inside a vehicle, but in that case the risk of failure is way higher.
Edit 2: Concerning the mind control magic mechanics. When a mage weaves a mind control spell, they send a special signal to a target, containing a specific order. If the target fails to resist the spell, they obey the order without any questions. However, if the victim was cursed by a relatively inexperienced mage, there is a chance that the hypnotized person might break free from the spell, if they have strong willpower. Alternatively, a wizard can maintain persistent connection to the target, thus turning the victim into their willess puppet who does anything its master wants. As for the limits of this ability, it all comes down to the individual wizard's mastery over magic. The most powerful mages can singlehandedly enslave entire platoons for many hours, while your average infantry level sorcerers can control at best a few soldiers for less than a minute. Those, who are exceptionally skilled at MC magic, are capable of influencing the others minds imperceptibly - picture the Indoctrination from Mass Effect. Their victims, while remaining fully aware, can't help but obey the orders they were given. However, such mages can be literally counted on the fingers of one hand. As for detecting the signs of mind control by magical means (once the muggles have turncoats) - again it all boils down to who cursed a person with a MC spell. If it was a highly professional wizard at work, it's unlikely that, say, a L2 turncoat mage could tell if something's wrong.