I'm trying to run a powershell backup script as a scheduled task, and as a part of this I need to map a network drive (before copying the backup to the remote host).
Now, this was working when I had it like this:
NET use $RemoteDir $RemoteUser $BackupPass
But due to security concerns, I can't keep the password in plain text, or anywhere on the server. So, my hope was that, since it's run as a scheduled task, 'NET' would be able to "inherit" the credentials from the user running the scheduled task, so that it could be run like this:
NET use $RemoteDir
But it doesn't seem to work, when I log the error I get:
The password is invalid for <RemoteDir>.
Enter the user name for <RemoteDir>':
So, my question is: Is there any way to get this to work? I.e. having NET use the credentials that the scheduled job is running with? Or do I need to find another approach?
Edit: Forgot to mention, the user running the scheduled task is a domain user, and it has access to the remote.
Thanks!
Create a domain account. Assign the account permissions to the share and NTFS directory. Set the task to execute under the account you just created.