Modules
Modules copied to clipboard
Secret management - secrets and vault can be use in schedule tasks
Summary of the new feature/enhancement
in Microsoft.PowerShell.SecretManagement, secrets can be use in scripts scheduled.
Proposed technical implementation details (optional)
@harsh26690 I don't have a problem with scheduled tasks, keep in mind though that usually scheduled tasks, unless you specify a different user, run under SYSTEM, so you have to set the secrets as SYSTEM (I usually use psexec to get a system console), because secrets are saved in the Windows Credential Manager which is per-user.
Can you provide more detail to the issue you're facing?
@JustinGrote i need to automate tasks by orchestrator runbook...
command it runs -
"%ProgramFiles%"\PowerShell\7\pwsh.exe -Command "& C:\RunBooks\ExchangeTasks\MailboxesPerDatabases\MailboxesPerDB-withsecretmanagement.ps1"
i have saved secret and calling it by $cred=get-secret -name
Let me know if you want more insides
What account does your sched task run under? Did you run set secret in the same context? You could also try a simpler script to just get-secret and output it to a text file to verify.
@JustinGrote there is no account specify here.. secret saved in cred manager for current user only, so secret set by user A only works for user A. No output I got in text file. Please check some screen shot what i have. secret-powershell-issue.docx
You should use psexec -I -s pwsh to get a SYSTEM account prompt and set the password there. Alternatively, edit your scheduled task to run as the same user you set your secret under.