PS > Get-Item env: | Select-Object -First 1 | ForEach-Object GetType
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False True ValueCollection System.Object
PS > (Get-Item env:) | Select-Object -First 1 | ForEach-Object GetType
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True DictionaryEntry System.ValueType
Preamble:
I was wondering why I cannot use Where-Object to filter Get-Item env:
P.S. Just in case, the solution to filter env:
(Get-Item env:) | Where-Object Name -eq 'PUBLIC'Get-Item env:\* | Where-Object Name -eq 'PUBLIC'Get-ChildItem env: | Where-Object Name -eq 'PUBLIC'gi env: |% GetEnumerator |? Name -eq 'PUBLIC'(added after @santisq answer, he deleted it)
However despite of the fact thar Get-Item env: list all the env variables (however the documentation said it should not while * is not set pointed), you cannot filter Get-Item env: | Where-Object Name -eq 'PUBLIC because Get-Item env: | Measure-Object Count is 1
Environment: PSVersion 5.1.19041.610