SecretManagement Get-Secret using tab completion for the -Name parameter, before any command is run, then user interaction (writing to output or prompting) is disabled.
PS C:\> Get-Secret 'hello <hit tab key here>
Get-Secret: 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.
Result:
Error message to provide password by running Unlock-SecretStore
Expected:
Prompt for password
This happens because the runspace created to run the tab completion Get-SecretInfo in has no host UI, since none is available at that time.
Fix is to detect this condition and recreate the runspace when a host with UI (non-Default host) is available.
SecretManagement
Get-Secret
using tab completion for the-Name
parameter, before any command is run, then user interaction (writing to output or prompting) is disabled.This happens because the runspace created to run the tab completion
Get-SecretInfo
in has no host UI, since none is available at that time.Fix is to detect this condition and recreate the runspace when a host with UI (non-Default host) is available.