ironmansoftware / powershell-universal

Issue tracker for PowerShell Universal
https://powershelluniversal.com
34 stars 2 forks source link

$Job.Children returning all job objects #3445

Closed mikedhanson closed 1 month ago

mikedhanson commented 1 month ago
          I think this introduced a new bug 

Job: 14743
image

as you can see this job has 4 child jobs. None of these child jobs have children.

$Job = Get-psujob -id 14743 -UseDefaultCredentials -ComputerName http://localhost:5000

$Job.Children.id

image

image

Originally posted by @mikedhanson in https://github.com/ironmansoftware/powershell-universal/issues/3433#issuecomment-2214315346

adamdriscoll commented 1 month ago

I can reproduce this. This is happening in over HTTP but not in the integrated environment. We'll have a fix for this in 4.3.3.

mikedhanson commented 1 month ago

MusicalCockroachesGIF

mikedhanson commented 1 month ago

Still seeing this issue on 4.3.3

image

adamdriscoll commented 1 month ago

I can't reproduce this.

image

PS C:\src\universal\src> (get-psujob -Id 5).Children | measure

Count             : 4
Average           :
Sum               :
Maximum           :
Minimum           :
StandardDeviation :
Property          :

PS C:\src\universal\src> Get-PSUInformation

Version BuildVersion
------- ------------
4.3.3   {"version":"2441366528"}

PS C:\src\universal\src> Get-Module Universal

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     4.3.3                 Universal                           {Clear-PSUCache, Connect-PSUEventHub, Connect-PSU…

Can you try to invoke the API directly?

Invoke-RestMethod 'http://localhost:5000/api/v1/job?trigger=true&child=true&take=100&parentId=15170' -UseDefaultCredentials

It should return a Page of jobs with a total property.

PS C:\src\universal\src> (Invoke-RestMethod 'http://localhost:5000/api/v1/job?trigger=true&child=true&take=100&parentId=5' -Headers @{ Authorization = "Bearer $AppToken" }).Total
4

What's interesting is that the cmdlet now limits it to 100 child jobs so it should never return more than 100.

mikedhanson commented 1 month ago

@adamdriscoll - It was my issue. I never restarted my terminal and the universal module was still showing 4.3.2. After restarting the powershell process it seems to be working with 4.3.3 cmdlets

mikedhanson commented 1 month ago

image