Closed HFS-CG closed 1 year ago
Hi @HFS-CG. After creating a new session, you can call Invoke-VenafiRestMethod -UriLeaf 'certificates/' -Body @{'Serial'='1234567890'}
. Get is the default method and VenafiSession will come from the session parameter automatically set so you don't need to provide those directly. Note the trailing slash after certificates.
Why not use Find-VenafiCertificate -SerialNumber '1234567890'
?
Thank you! A trailing slash on UriLeaf = "Certificates/"
did the trick! :D
Figures that something so simple would send me down a days-long rabbit-hole.
(Would be super-cool if the Examples in the Help for Invoke-VenafiRestMethod
included a "Get Certificates/" example)
Invoke-VenafiRestMethod exists for those APIs which don't have dedicated functions so we wouldn't look to add this as an example.
@gdbarron
For background ; I want to create a Check-TppCertificateAssociation
function using Invoke-VenafiRestMethod
because only Add-TppCertificateAssociation
& Remove-TppCertificateAssociation
exist in the VenafiPS
module (so there's a 'gap' in functionallity).
Before I embark on such a task, I first wanted to confirm I knew how to reliably use Invoke-VenafiRestMethod
by doing something less impactful than the examples provided in the Help for Invoke-VenafiRestMethod
(like a "Get certificate info").
No reason why you can't use existing functions in the module within other functions. Better to reuse an existing function than duplicate code. The only thing to keep in mind is you must pass -VenafiSession in case someone doesn't use the session variable.
Also, I'd suggest Test-
instead of Check-
as the latter isn't an approved verb.
I want to create a
Check-TppCertificateAssocation
function usingInvoke-VenafiRestMethod
. To start with, I'm trying to perform a simple query for basic info on a certificate - mainly to be sure I'm usingInvoke-VenafiRestMethod
correctly.After running
New-VenafiSession
to authenticate to our TPP implementation, I runInvoke-VenafiRestMethod
with what appears to be the correct parameters, with no success thusfar. I've been at this for two days now, and have tried specifyingserial=
,thumbprint=
,CN=
andCertificateDN=
Invoke-VenafiRestMethod
throws 401 (not authorized) error when using the below code; (note the below does not contain the actual Serial number and TPP server)After a good bit of thrashing and a replacement keyboard, I've managed to get
Invoke-VenafiRestMethod
to complete successfully, however returns nothing (no error, no output,$?
showstrue
);I've done a lot of searching and reading (cmdlet's help, all "Issues", google, Venafi Warrior community, etc) trying to figure out what I'm doing wrong, but to no avail.
I'm sure I'm missing something important or doing something silly - any light you could shed would be most appreciated!