I want to use SecretStore in automation, however, I am not able to get rid of the password prompt. The steps I took are as follows:
1- Reset SecretStore -> Asks for password (mandatory).
2- Setting the interaction to None -> Returns error.
3- Unlock -> Asks for password
The output can is listed below:
PS /home/mahmood> Reset-SecretStore -PassThru
WARNING: !!This operation completely removes all SecretStore module secrets and resets configuration settings to new values!!
Reset SecretStore
Are you sure you want to erase all secrets in SecretStore and reset configuration settings to default?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
Creating a new Microsoft.PowerShell.SecretStore vault. A password is required by the current store configuration.
Enter password:
************
Enter password again for verification:
************
Scope Authentication PasswordTimeout Interaction
----- -------------- --------------- -----------
CurrentUser Password 900 Prompt
PS /home/mahmood> Set-SecretStoreConfiguration -Interaction None
Confirm
Are you sure you want to perform this action?
Performing the operation "Changes local store configuration" on target "SecretStore module local store".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
PS /home/mahmood> Get-SecretStoreConfiguration
Get-SecretStoreConfiguration: A valid password is required to access the Microsoft.PowerShell.SecretStore vault.
Use the Unlock-SecretStore cmdlet to provide the required password to access the store.
PS /home/mahmood> Unlock-SecretStore
cmdlet Unlock-SecretStore at command pipeline position 1
Supply values for the following parameters:
Password: ************
PS /home/mahmood> Get-SecretStoreConfiguration
Scope Authentication PasswordTimeout Interaction
----- -------------- --------------- -----------
CurrentUser Password 900 None
As you can see, although the interaction is now "None", however, when I rerun pwsh command, the get configuration doesn't work again.
PS /home/mahmood> exit
mahmood@Frontend:~$ pwsh
PowerShell 7.1.3
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
PS /home/mahmood> Get-SecretStoreConfiguration
Get-SecretStoreConfiguration: A valid password is required to access the Microsoft.PowerShell.SecretStore vault.
Use the Unlock-SecretStore cmdlet to provide the required password to access the store.
How can I fix that?