Thanks everyone for your various suggestions.
@Rob Simmers - the script opens a web browser to the Microsoft Store page for downloading Thunderbolt Control Center, allowing the user to download, install, and then run Thunderbolt Control Center to detect the drive when it is unplugged and plugged back in; and hit a key when done. Then the script uninstalls Thunderbolt Control Center, and reboots the machine. This is all necessary to get the Thunderbolt services working sufficiently for Windows to see the drive. Quite what Thunderbolt Control Center is doing, I am not sure, because although Thunderbolt Control Center can see the drive, it can’t do anything with it (it presents an option for the user to authorise the drive but that has no effect, since the machine doesn’t yet have a BIOS option to configure Thunderbolt, so can’t send authorisation over the header cable). Yet Thunderbolt Control Center does something that enables Windows to see the drive - not immediately, but after a restart, and only when Thunderbolt Control Center has been uninstalled again!
For details of the relevant saga, see
So I don’t want to run it after a warm boot when it is not necessary, because it requires user input and because it reboots the machine.
@Faris and @ChrisM_Cologne69 - thanks - the Reason for a 1074 seems to be the same on cold boot and warm reboot; investigating a combination of other events would seem to be necessary to distinguish between cold and warm boots.
In the end it seems quicker to achieve what I need by testing for the presence of the drive, which is after all what I need to establish, using:
$Disk = Get-WmiObject -Class Win32_logicaldisk -Filter “VolumeName = ‘Samsung_X5’”
if ( $Disk.VolumeName -neq ‘Samsung_X5’ )
[The whole script goes in here…]