SecretManagement.PleasantPasswordServer.Extension/Public/Get-SecretInfo.ps1
function Get-SecretInfo { param ( [Parameter(Mandatory)] [string] $VaultName, [Parameter()] [string] $Filter, [Parameter()] [hashtable] $AdditionalParameters ) trap { Write-VaultError -ErrorRecord $_ } $Token = Invoke-LoginToPleasant -AdditionalParameters $AdditionalParameters $headers = @{ "Accept" = "application/json" "Authorization" = "$Token" } $body = @{ "search" = "$Filter" } $PasswordServerURL = [string]::Concat($AdditionalParameters.ServerURL, ":", $AdditionalParameters.Port) $Secrets = Invoke-RestMethod -method post -Uri "$PasswordServerURL/api/v5/rest/search" -body (ConvertTo-Json $body) -Headers $headers -ContentType 'application/json' $id = $Secrets.Credentials.id if ($id.Count -gt 1) { throw "Multiple ambiguous entries found for $Name, please remove the duplicate entry" } if ($null -eq $id) { throw "No secret with $Name is found" } return [Microsoft.PowerShell.SecretManagement.SecretInformation]::new( $Filter, [SecretType]::PSCredential, $VaultName ) } |