Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit 5271ab0

Browse files
author
PowerVCF
authored
Update PowerVCF.psm1
1 parent d521525 commit 5271ab0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

PowerVCF.psm1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,10 +3147,17 @@ Function Get-VCFTask {
31473147
}
31483148
if ($PsBoundParameters.ContainsKey("id")) {
31493149
$uri = "https://$sddcManager/v1/tasks/$id"
3150+
Try {
31503151
$response = Invoke-RestMethod -Method GET -URI $uri -headers $headers
3152+
}
3153+
catch {
3154+
if ($_.Exception.Message -eq "The remote server returned an error: (404) Not Found.") {
3155+
Write-Output "Task ID Not Found"
3156+
}
3157+
}
31513158
$response
31523159
}
3153-
if ($PsBoundParameters.ContainsKey("status")) {
3160+
elseif ($PsBoundParameters.ContainsKey("status")) {
31543161
$uri = "https://$sddcManager/v1/tasks/"
31553162
$response = Invoke-RestMethod -Method GET -URI $uri -headers $headers
31563163
$response.elements | Where-Object { $_.status -eq $status }
@@ -4675,4 +4682,4 @@ Function Debug-CatchWriter {
46754682
}
46764683
Export-ModuleMember -Function Debug-CatchWriter
46774684

4678-
######### End Useful Script Functions ##########
4685+
######### End Useful Script Functions ##########

0 commit comments

Comments
 (0)