I have been using the Powershell Scheduled Task Cmdlets to create a scheduled task on our servers.
How do I elect to \'Run whether user is logged in or not\' using
You need to remove $principal and register the task with a user and password:
Register-ScheduledTask -TaskName $taskname ` -TaskPath "\my\path" ` -Action $action ` -Trigger $trigger ` -User "$env:USERDOMAIN\$env:USERNAME" ` -Password 'P@ssw0rd' ` -Settings $settings