Hi,
I'm writing a PowerShell script that simply copies a specific file to a SharePoint folder. The plan is to have this script run on schedule unattended each day. SharePoint requires credentials to store the file and I'm stuck on how to handle the credentials. My plan is to run this as a scheduled task in the system account using a service account to access SharePoint. I have tested this and it works manually, entering the SharePoint credentials through the keyboard, but I'm stuck on how to automate this.
Doing some research I believe the best approach would be to use the ConvertTo-SecureString and Export-Clixml to store the credentials in a secure file that I can read in when needed. I've seen numerous examples on how to do this.
However, considering the limitation of this approach being you must use the same user account on the same computer I'm not sure how to proceed. Is my only option to allow my service account to run on the server? I normally don't log on to servers with service accounts, guess I always thought this wasn't a good practice.
So I'm looking for suggestions. Is this the best approach or is there a better way to handle these credentials? Do I have to run the scheduled task as the service account?
Thanks in advance!