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

The absence of the 'secretmanagement' directory seems to modify the behavior of the Unregister-SecretVault cmdlet #119

Open
LaurentDardenne opened this issue Mar 19, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@LaurentDardenne
Copy link

Expected use :
image
Get-SecretVault return nothing.

Now I delete the 'secretmanagement' directory
image

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.610
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.19041.610}
BuildVersion                   10.0.19041.610
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Repro:

get-module

import-module Microsoft.PowerShell.SecretManagement
import-module Microsoft.PowerShell.SecretStore
#first installation
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
Get-SecretVault
# Name        ModuleName                       IsDefaultVault
# ----        ----------                       --------------
# SecretStore Microsoft.PowerShell.SecretStore True

Get-SecretVault|Unregister-SecretVault
Get-SecretVault
#nothing
dir $env:USERPROFILE\AppData\Local\Microsoft\PowerShell

Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
del $env:USERPROFILE\AppData\Local\Microsoft\PowerShel\secretmanagement\
Get-SecretVault|Unregister-SecretVault
Get-SecretVault
# Name        ModuleName                       IsDefaultVault
# ----        ----------                       --------------
# SecretStore Microsoft.PowerShell.SecretStore True

Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
#Errror  : Register-SecretVault : Provided Name for vault is already being used.

When a close the current session and open a new session, Get-SecretVault return nothing.

It's not really a bug but a special case I think.

@PaulHigin
Copy link
Contributor

This behavior is by design. The vault registry information is cached in memory and only updated when file contents change. But I agree the missing directory behavior should be better. I am thinking SecretManagement should try to re-create the directory/registry file, which it does anyway after PowerShell is restarted.

@PaulHigin PaulHigin added the bug Something isn't working label Mar 22, 2021
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