We have one Task Scheduler job using Credential Manager to store service account credentials(Generic). After a password change, we started facing this issue. We have a PowerShell script configured as a Task Scheduler job that uses Credential Manager to validate and manage credentials. The script works fine from the PowerShell console but returns null for the username and password when run from Task Scheduler.
Get-StoredCredential -Target "XYZ" : returning Null Value
We have tried the following option: set a new credential in the script, ran it one time, and then removed it.
New-StoredCredential -Target "" -UserName "" -Password "" -Persist LOCAL
Custom Logs-
08:00:11.8435 Information Init-Logger Starting process...
08:00:12.0623 Information Get-Assembly Credentials Manager loaded
08:00:12.1873 Error Get-SPOContextByCredMngr Exception calling ".ctor" with "2" argument(s): "The 'username' argument cannot be null.
Parameter name: username"
Could you please suggest any solution to this problem?