I have built a script which is using an API to retrieve data from an application and put it in a CSV. I am looking to create a scheduled task so that it can run on a daily basis. Now whenever I open a new PowerShell session and run the script, it prompts me to enter my client ID & Client Secret. I want a way around this as the scheduled task I’ll create would open a new PowerShell session every time it runs. I have tried various methods like saving my credentials in a file and then retrieving the same using the script, however, every time I run it in a new PowerShell session, it asks me to enter the API credentials. Let me know if you require any other information I may have missed out. Thanks in advance!
Welcome to the forum.
How about sharing your actual code? Without that it will be nearly impossible to advise something meaningful.
And please … When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance
How to format code in PowerShell.org 1 <---- Click
(Sometimes the “preformatted text” button hides behind the gear symbol )
Thank you for your response. I was working on this yesterday and was finally able to run the code without having to enter the credentials. I used a variable to store my credentials and called it in my code with the help of Microsoft.PowerShell.SecretStore module.
Anyway, highly appreciate your prompt response on my question. It’s feels wonderful to join such a helpful community.
Hey, that’s really great. How about sharing your solution anyway? That could help others comming here looking for help for the same or a similar issue.
The solution lies in the below article,