Skip to content

Cannot use output from Get-SecretInfo in -CredentialInfo parameter (no cast from SecretInformation to PSCredentialInfo) #1556

Open
@sean-r-williams

Description

@sean-r-williams

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

  • Register a secret store per SecretStore/SecretManagement module
  • Register a repository with PSResourceGet via Register-PSResourceRepository
  • Call Set-PSResourceRepository -Name <repo> -CredentialInfo (Get-SecretInfo -Vault <vault> -Name <secret>)

Expected behavior

PS> Set-PSResourceRepository -Name Artifactory -CredentialInfo (Get-SecretInfo -Vault "Default" -Name "Artifactory")
PS> # no error

Actual behavior

PS> Set-PSResourceRepository -Name Artifactory -CredentialInfo (Get-SecretInfo -Vault "Default" -Name "Artifactory")
Set-PSResourceRepository : Cannot bind parameter 'CredentialInfo'. Cannot convert the "Microsoft.PowerShell.SecretManagement.SecretInformation" value of type "Microsoft.PowerShell.SecretManagement.SecretInformation" to type
"Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo".
At line:1 char:93
+ ... dentialInfo (Get-SecretInfo -Vault "Default" -Name "Artifactory") ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-PSResourceRepository], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.PSResourceGet.Cmdlets.SetPSResourceRepository

Error details

Set-PSResourceRepository : Cannot bind parameter 'CredentialInfo'. Cannot convert the "Microsoft.PowerShell.SecretManagement.SecretInformation" value of type "Microsoft.PowerShell.SecretManagement.SecretInformation" to type
"Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo".
At line:1 char:93
+ ... dentialInfo (Get-SecretInfo -Vault LocalUser_Auto -Name Artifactory_a ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-PSResourceRepository], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.PSResourceGet.Cmdlets.SetPSResourceRepository

Environment data

PS> Get-Module Microsoft.PowerShell.PSResourceGet; $PSVersionTable | ft

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.2      Microsoft.PowerShell.PSResourceGet  {Find-PSResource, Get-InstalledPSResource, Get-PSResourceRepository, Get-PSScriptFileInfo...}



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

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions