If you take the sleeper you can go all the way to Inverness without a change...
"
Caledonian Sleeper – Highlander Route
Six nights each week, Caledonian Sleeper services depart from Aberdeen, Inverness and Fort William. The Aberdeen train takes in a number of major stops, including Dundee, Leuchars (for St Andrews), Stonehaven and Montrose. The Inverness service visits stations including Aviemore, Perth, Pitlochry, Gleneagles and Stirling. The Fort William service calls at destinations including Rannoch, Corrour (the UK’s most remote station), Crianlarich and Helensburgh Upper.
Northbound, the Caledonian Sleeper leaves London Euston in the evening before splitting into three at Edinburgh Waverley in the early hours of the morning. The three sections arrive at Aberdeen, Inverness and Fort William.
"
https://www.sleeper.scot/our-route/