Venafi / VenafiPS

Powershell module to fully automate your Venafi TLS Protect Datacenter and Cloud platforms!
https://venafips.readthedocs.io/
Apache License 2.0
17 stars 8 forks source link

Error when using Get-VdcAttribute with -All parameter #259

Closed Alex-Gomez-Lopez closed 4 months ago

Alex-Gomez-Lopez commented 5 months ago

Environment

Full Operating System: Windows Server 2019 Datacenter, version 1809, build 17763.2061
VenafiPS version: 6.1.4
PowerShell version: 5.1.17763.1971
TLSPDC version (if applicable): TPP 22.4.6 standalone.

Steps to reproduce

Run this command:

Get-VdcAttribute -Path "\VED\Policy\Certificates\Enhanced_Report\cert01.reports.hsbc.corp02.com" -All -NoLookup

In case it is relevant, the OAuth token was obtained through this call:

New-VenafiSession -Server $server -ClientId $clientId -Scope @{'certificate'='' ; 'configuration'=''} -Credential $global:cred

Where credentials correspond to a Master Admin and $clientId corresponds to an API integration that includes certificate + configuration scopes and which the Master Admin is allowed to use (so no error is received when generating the token and, in fact, other Web SDK calls work correctly).

Expected behavior

The Get-VdcAttribute command with the parameters from above should work without issues. If anything, a warning that using PowerShell Core v7+ could make the call work much faster, but no error in red.

Actual behavior

The error below can be seen, see also first provided screenshot:

Invoke-VenafiRestMethod : Cannot bind parameter because parameter 'UriLeaf' is specified more than once. To provide multiple values to parameters that can accept multiple values, use the array syntax. For example, "-parameter
  value1,value2,value3".
  At line:20 char:61
  + ...          $response = Invoke-VenafiRestMethod @params -UriLeaf 'Config ...
  +                                                          ~~~~~~~~
      + CategoryInfo          : InvalidArgument: (:) [Invoke-VenafiRestMethod], ParameterBindingException
      + FullyQualifiedErrorId : ParameterAlreadyBound,Invoke-VenafiRestMethod

Note that result of the command is displayed after that error, so the command does what is is meant to do but the error message is confusing and inconvenient.

Interestingly, other calls work nicely without errors. That includes the same Get-VdcAttribute command with a specific attribute instead of requesting all of them (see also second provided screenshot):

PS C:\Users\Administrator> Get-VdcAttribute -Path "\VED\Policy\Certificates\Enhanced_Report\cert01.reports.hsbc.corp02.com" -Attribute Organization -NoLookup

Name         : cert01.reports.hsbc.corp02.com
Path         : \VED\Policy\Certificates\Enhanced_Report\cert01.reports.hsbc.corp02.com
TypeName     : X509 Server Certificate
Guid         : 4f09018a-181a-4d04-bcd3-e5c869c9cae6
Attribute    : {@{Name=Organization; Locked=False; PolicyPath=\VED\Policy\Certificates\Enhanced_Report; Value=HSBC; Overridden=False}}
Organization : HSBC

PS C:\Users\Administrator>

Screenshots

image

image