This going to be difficult to explain but I will try convey my issue as best I can.
I have a powershell script that calls a REST API to backup a vCenter Server. The script gets triggered nightly via a scheduled task running on a Windows 2016 server (Win16). The task runs under a service account that has admin rights but does not have logon interactive rights on Win16.
I have a script that configures the scheduled task by doing the following.
- When one logons on to Win16 as an administrator and run the configuration script you are prompted to provide two sets of credentials, one for the service account under which the task runs and one for access to the vCenter REST API, backup account. I store the creds as two separate credentials objects
- I then invoke a "remote" PS session to the Win16 server under the user context of the service account and pass the credentials object through to the "remote" session.
- From within the remote session I then export the credentials object to, two separate files. These files are used in the backup script called via the scheduled task, to authenticate to the vCenter REST API.
The issues I am having is when I try to automate this process for testing purposes. My automation process is basically as follows:
- Check if Win16 server has any vmware snapshots, if it does revert the snapshot, then delete, then create a new snapshot - at this point I have a fresh windows server.
- I then deploy my scripts and run through the configuration process - using Jenkins and Invoke-build pipelines, all done using invoke-command from the Jenkins servers.
- Now because I cannot respond to the prompts for the creds input, I bypass this step and just copy the xml files created in the manual process. and then create the scheduled task.
Any ideas why this is the case and how I could work around it.