Venafi / VenafiPS

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

Error Message indicates that VenafiSession is requiered, when an error occurs with another parameter #210

Closed sabixx closed 1 year ago

sabixx commented 1 year ago

Environment

Operating System: Windows 2019+
VenafiPS version: v5.5.1
PowerShell version: 
TPP version (if applicable):

Steps to reproduce

Provide a parameter with wrong settings. e.g. Remove-TPPObject -Path $cert.Path -Confirm $false

The error in the above example is with Confirm $false, correct would be Confirm:$false. but the error that's being displayed is

Please run New-VenafiSession or provide a Vas key or TP token. At ...C:...path...\ Test-VenafiSession.ps1:78 char:17 throw "Please run New-Venafisession or provide a Vaas key

Expected behavior

The error shall provide feedback of the actual parameter with the issue.

Actual behavior

The error that is provided seems like the VenafiSession is missing.

Screenshots

image
gdbarron commented 1 year ago

Looks like PowerShell is taking $false as the second positional parameter and assigning it to $VenafiSession.

image

This overwrites the script scoped $VenafiSession variable that was set when you ran New-VenafiSession. Then Test-VenafiSession gets called with $false as the value and fails.

image

Not much to be done here. There is an example for -Confirm usage so hopefully this helps.