Credential Management

lkubler 41 Reputation points
2020-10-07T13:18:11.15+00:00

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!

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 123.8K Reputation points MVP Volunteer Moderator
    2020-10-07T21:57:41.127+00:00

    If you use the Task Scheduler of Windows it's possible to specify a user account which is used to run the scheduled task (Task Scheduler ->Task -> General Tab -> "When running the task use the following user account").

    Maybe this is helpful.

    Regards
    Andreas Baumgarten

    (Please don't forget to Accept as answer if the reply is helpful)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.