Closed rogerramtech closed 3 years ago
Yeah, I can see how that would prove pretty confusing.
When you call Get-Command 'Get-Blank'
and pipe that to Get-Member
, you're passing the meta-object that represents the function itself. What the koan is doing is actually invoking that meta-object to run the function, using &
.
So what you would need to be looking at is instead:
& (Get-Command 'Get-Blank') | Get-Member -MemberType Property
This might just error though, I think? Either that or probably not return anything.
I'd expect Get-Blank
to be a difficult one to use here; by design it emits an object that tries its utmost to behave as close to $null
as possible while also doing a bit of subterfuge to make certain patterns easier for the module to present to users without also triggering a large amount of very confusing errors.
Ah! I see the issue now. They had tried a bunch of commands filtered by
Get-Command -CommandType Cmdlet
and happened to get a whole bunch (~15) all with Null returns. I can see that it does work, but you have to be very judicious about the Cmdlets you pick. To use your example...
& (Get-Command -Name 'Get-Process') | Get-Member -MemberType Property -Name 'Threads'
TypeName: System.Diagnostics.Process
Name MemberType Definition
---- ---------- ----------
Threads Property System.Diagnostics.ProcessThreadCollection Threads {get;}
Just a matter of picking the right Cmdlet Property combo to return a result. Surprising how many don't. Particularly if you stray away from -Verb Get
Thanks.
Yeah, for the most part you won't get a lot of data / properties from non-Get cmdlets. There are exceptions, as with anything, but the majority of things that emit output are Get-*
.
Glad you got it sorted out! 💖 🌸
Describe "Koan Bug, Issue, or Help Request"
I have my team using PSKoans as some additional training. A few have struck the following problem in the AboutGetMember topic in the foundation module.
Returns
Context "The Problematic Assertions"
Context "Your Attempts"
I have attempted this on various device and in various environments. It doesn't seem to happen in pwsh Version 7.1.2 but this is not conclusive, as the devices and OS are also different. the environment that this does occur in are as follows.
I have attempted the following in the same environment and get these successful results. I have also tried with many other cmdlets, with the same outcome. The only way to get past it seems to be to comment out the entire assertion and Topic.
Clearly not empty or $null. So why is the It assertion say it is? This issue does not happen in the MacOS version using 7.1.2 core. I have not tested in 5.1 or lower.
Context "Additional Information"
Any assistance appreciated.