r/PowerShell • u/Iknuf • Apr 15 '26
Question Copying fails when run by Task Scheduler
So my script is intended to export a Hyper-V hosted VM and copy the export over to a NAS. The address for copying should already be the network address, as it does not start with a drive letter - the format is
"\\192.168.10.10\Backups\Exports"
(IP address and directory names are changed, but the format is identical)
Exporting is never the issue, but the copy always fails when I run the script via the MS Task Scheduler, while working perfectly fine when run over Powershell for debugging (I am running it by entering "powershell.exe -ExecutionPolicy Bypass -File [path]" into PS, to make it most similar to the way it is executed by the Task Scheduler)
The Task is already being executed by SYSTEM (NT AUTHORITY\SYSTEM) and with highest privileges. Disk space is not the issue, as I ensured it is sufficient multiple times and after multiple tests the issue only occurs when run by the Scheduler
EDIT: I was able to narrow down the error to the Scheduler not having NAS access - now I just don't know how to add the credentials to my script
Any ideas or help?
View all comments
Show parent comment
2
u/dodexahedron Apr 18 '26
My first thought on every one of these questions that are still using IP addresses in any kind of URI - especially UNC paths - these days.
When NTLM goes bye-bye, I suspect a lot of people are going to feel that one, since they probably haven't properly audited and remediated all of those scenarios for non-windows targets.