truck will crank in park and you can shift to reverse and still runs but when you shift to neutral or drive engine shuts down and losses spark. have installed 2 new park neutral switches and they do the same thing. have plugged one in not installed on the truck with the switch in park so it would crank then put it in drive and truck runs but the trans will not shift.
Maybe ignition switch looses power when the shifter is moved? Tough to say but luckily you are experiencing a loss of spark. Since you know you are not getting spark all you need to do is diagnose it. I have created a no start diagnostic chart that provides steps to assist in diagnosing an issue.