Skip to content

Cannot use Set-SecretStorePassword with parameter arguments to set a new password, without an existing password #94

@Kaiyiccc

Description

@Kaiyiccc

I'm trying to set a new password for SecretStore using parameter arguments rather than interactively.

Based on what's written in the documentation, something like this should work when no password have been previously set:

Set-SecretStorePassword -NewPassword $newPassword

However I'm getting this error and cannot leave the -Password argument blank, no matter my input type:

PS C:\Users\k> Set-SecretStorePassword -NewPassword $MyCredential.Password
Set-SecretStorePassword : Cannot bind parameter 'NewPassword'. Cannot convert the "System.Security.SecureString" value
of type "System.String" to type "System.Security.SecureString".
At line:1 char:38
+ Set-SecretStorePassword -NewPassword System.Security.SecureString
+                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-SecretStorePassword], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.SecretStore.SetSecretStorePasswordCo
   mmand

PS C:\Users\k> pSet-SecretStorePassword -NewPassword '123'
Set-SecretStorePassword : Cannot bind parameter 'NewPassword'. Cannot convert the "123" value of type "System.Int32"
to type "System.Security.SecureString".
At line:1 char:38
+ Set-SecretStorePassword -NewPassword 123
+                                      ~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-SecretStorePassword], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.SecretStore.SetSecretStorePasswordCo
   mmand

Relevant documentation below:

Set-SecretStorePassword
-NewPassword
[-Password ]

with

-Password
Existing password needed to unlock the store. This can be ignored if the store doesn't currently use a password.

Any idea how to fix this? Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions