I have a PowerShell script that enables Windows Mobile Hotspot automatically when an Ethernet connection is active. The script works when I run it manually, and it also works when I start the scheduled task after Windows has finished booting. However, a Task Scheduler trigger set to "At startup" does not appear to run—the Last Run Time remains from the last manual launch.
The task action runs `powershell.exe` with `-ExecutionPolicy Bypass -File "C:StartupScriptsTurnOnHotspot.ps1"`. The script uses the Windows Networking WinRT APIs to check for an Ethernet connection and start tethering asynchronously. The task already has a startup delay, runs under my user account, and is configured to run with elevated privileges. What could prevent the task from running successfully at startup?
3 Answers
At the very early startup stage, Windows may not have finished initializing the network adapter or the related networking services. Try changing the trigger from “At startup” to “At log on,” or increase the startup delay. In this case, switching to a logon trigger appears to have solved it.
Add simple `Add-Content` logging statements throughout the script so you can tell whether Task Scheduler starts it and where it stops. Also verify the task’s history and Last Run Result rather than relying only on Last Run Time. Other useful checks are running it as SYSTEM or the intended user, enabling “Run with highest privileges,” and adding a longer startup delay.
Check the Conditions tab, especially the power options. Settings such as “Start the task only if the computer is on AC power” or stopping the task when power changes can prevent a startup task from running, even when the machine appears to be connected to power. Disabling those restrictions may resolve the issue.

That was probably the fix. I also changed the power-related settings, so one of those two changes may have been responsible.