Badgerati / Pode

Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
https://badgerati.github.io/Pode
MIT License
845 stars 92 forks source link

Set-PodeCache not working as expected with piped array #1343

Closed AdeeelAsif closed 2 weeks ago

AdeeelAsif commented 3 months ago

Describe the Bug

Set-PodeCache is not working as expected with a piped array. When I try to retrieve the cache value using Get-PodeCache, it only shows me the last value of the array, not the entire array.

Steps To Reproduce

Steps to reproduce the behavior:

$test = $backendAddressPools | ForEach-Object {

                $fqdn = $.BackendAddresses.Fqdn
                $namespace = "Prd1" # Par défaut

                $health = $backendHealth | Where-Object { $.Address -eq $fqdn } | Select-Object -ExpandProperty Health

                if ($health -notmatch "Unknown") {

                    [PSCustomObject]@{
                        AppGWName         = $AppGwName
                        BackendName       = $.Name
                        provisioningstate = $.ProvisioningState
                        fqdn              = $_.BackendAddresses.Fqdn
                        namespace         = $namespace
                        health            = $health
                        date              = get-date
                    }
                }
            }

$test | Set-PodeCache -Key "AppGateway.$($AppGwName)" -Ttl 300
Write-PodeJsonResponse -Value @($test)

The problem does not occur when using -InputObject instead of piping the array.

Badgerati commented 2 weeks ago

Resolved via #1388