powershell-module-for-vmware-cloud-foundation
powershell-module-for-vmware-cloud-foundation copied to clipboard
Get-VCFTask returns a different $_Exception.Message for VCF 5.1 than whats in the code
Code of Conduct
- [X] I have read and agree to the project's Code of Conduct.
PowerVCF
2.4.1.1000
VMware Cloud Foundation
5.1.0.0
PowerShell
7.4.1
Guest Operating System
Windows Server 2019
Environment Details
VCF 5.1.0.0 with vCenter 8U2a
Description
Using PowerVCF 2.4.1.1000 I believe running Get-VCFTask on VCF 5.1.0.0 fails due to wrong exception message if the task doesn't exist.
Example output on a task that does not exist:
PS D:\scripts> Get-VCFTask 619cc900-15c5-48c0-840f-0b245bf1f4b3
Script File: C:\Program Files\PowerShell\Modules\PowerVCF\2.4.1.1000\PowerVCF.psm1 Line: 4339
Relevant Command: $response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
Target Uri: https://00ab-vcf.sddc.vegvesen.no/v1/tasks/619cc900-15c5-48c0-840f-0b245bf1f4b3
Exception Message: Response status code does not indicate success: 404 ().
Error Message:
{
"errorCode": "TA_TASK_NOT_FOUND",
"arguments": [
"619cc900-15c5-48c0-840f-0b245bf1f4b3"
],
"message": "Task with ID 619cc900-15c5-48c0-840f-0b245bf1f4b3 not found",
"referenceToken": "8465IV"
}
If I change line 4341 in PowerVCF.psm1 on my server from:
if ($_.Exception.Message -eq "The remote server returned an error: (404) Not Found.") {
to:
if ($_.Exception.Message -eq "Response status code does not indicate success: 404 ().") {
which matches the Exception Message above, then the output looks more correct - output with changed msg:
PS D:\scripts> Get-VCFTask 619cc900-15c5-48c0-840f-0b245bf1f4b3
Get-VCFTask: Task with ID 619cc900-15c5-48c0-840f-0b245bf1f4b3 not found.
Line 4341 in my PowerVCF.psm1
corresponds to line 4411 here on github, not sure why they are different, maybe powershell gallery is to blame.
Expected Behavior
Expected Get-VCFTasks to write a simple error message, not display the full error message/failure
Actual Behavior
Write out full error
Steps to Reproduce
Grab PowerVCF 2.4.1 and run Get-VCFTask on a non-existing ID.
Log Fragments and Files
No response
Screenshots
No response
Additional Context
No response