Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlock-SecretStore randomly fails after running Reset-SecretStore #99

Open
3 tasks done
wilddev65 opened this issue Aug 15, 2022 · 0 comments
Open
3 tasks done
Labels
bug Something isn't working

Comments

@wilddev65
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

I am writing a script for setting up a vault for automation. The initial run of the script and setup of the new vault runs well. I then tested doing Reset-SecretStore to see what would happen if someone wanted to start again if they didn't know the passwords. This of course resets everything to defaults and I then ran 'Set-SecretStoreConfiguration -Authentication 'Password' -PasswordTimeout 3600 -Interaction 'None' -Confirm:$false' to have a longer timeout and to not prompt. As this command appears to reset the password cached by Unlock-SecretStore, I ran it again immediately after to have it available for the rest of the script. The next part begins with Get-SecretInfo to discover if any users are in the vault, so they can be added if needed.
This results in the following error:
Get-Secretinfo : 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.

I have attempted to put Unlock-SecretStore in different places in the script and even went to far as to run it before every command to get it to function as expected. There seems to be always a part where it randomly fails to supply the necessary password for the vault.

Expected behavior

Once Unlock-SecretStore is run, the password is cached and available to other commands being run by the script

Actual behavior

Random failure with an error to 'Use the Unlock-SecretStore cmdlet to provide the required password to access the store.'

Error details

Get-Secretinfo : 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.
At C:\GitLab\hpe-oneview-and-ilo-provisioning\HPiLO-Import.ps1:183 char:18
+ ...   $accounts = (Get-Secretinfo -Vault VenafiPS -ErrorAction Stop).Name
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power...cretInfoCommand:GetSecretInfoCommand) [Get-SecretInfo], PasswordRequiredException
    + FullyQualifiedErrorId : GetSecretInfoException,Microsoft.PowerShell.SecretManagement.GetSecretInfoCommand

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version

Using VS Code on Windows 10

Visuals

No response

@SydneyhSmith SydneyhSmith added the bug Something isn't working label Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants