When I run the task scheduler it gives me a (0x1) error code. Basically this is to copy all files on the desktop and place them in Google Drive.
Backup1.ps1
$action = New-ScheduledTaskAction -Execute 'Powershell.exe' -Argument 'C:\Users\User\Desktop\Backup2.ps1'
$trigger = New-ScheduledTaskTrigger -Daily -At 9am
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "BackUP Google Drive" -Description "Google Drive Backup"
Backup2.ps1
Copy-Item "C:\Users\User\Desktop\*" -Destination "G:\My Drive\BackUp" -Recurse -Force
The Backup2.ps1 works 100% of the time when running it under PowerShell alone. The problem is that the task scheduler isn't completing the task due to the (0x1) error.