Thieves left one of Scotland's most famous palaces vulnerable to lightning strikes during a wave of thefts across some of the country's historic monuments.
Metal thieves stripped Linlithgow Palace, West Lothian, of copper taping used to conduct lightning strikes from its roof to the ground.
The former royal residence was among 17 historic sites to be targeted.
There were 30 thefts at stately homes, castles and churches in three years.
Thieves have taken heavy stone carvings, Roman artefacts and the fixtures and fittings from historic monuments across the country.
Dryburgh Abbey, in the Scottish Borders, was broken into in 2015 and lost two medieval stone carvings, while nearby Melrose Abbey was robbed of a Roman statuette of a stag and Roman pottery items.
Last year, thieves managed to make off with two heavy "Forest of Dean stone" carvings from Dunkeld Cathedral, while staff at Duff House in Aberdeenshire discovered that an antique toilet pull chain had been taken.
Scotland's historical sites were also the target of scrap metal thieves, who stripped lead from Deer Abbey in Aberdeenshire and Crossraguel Abbey in Ayrshire.
Metal hand rails were stolen from Dunstaffnage Castle, Argyll, and Kilchurn Castle on the banks of Loch Awe, while one thief made off with the main door padlock from Castle Campbell, Clackmannanshire.
In 2015, one thief set their sights slightly lower, making off with 12 packs of toilet roll from Castle Campbell.
Documents released by Historic Environment Scotland revealed thieves stripped the lightning protection tape from Linlithgow Palace in 2014.
It is understood the lightning tape, supplied to 37 HES-operated buildings across Scotland by a specialist contractor, was replaced before serious damage happened.
The documents, detailing items listed as missing or stolen between 2014 and 2016, also revealed that HES staff mislaid the keys to St Andrews Castle, Fife, and a set of internal keys for Dunblane Cathedral.
In 2012, HES set up a task force with police and amateur enthusiasts to crack down on the growing problem of crime at historic sites.
Heritage chiefs consulted with both police officers and insurance companies to reduce the levels of crime being committed at historic sites, while creating an "early warning" network to target criminals who are breaking into properties and ransacking historic sites.