I’d like to write some PS code that will loop through the available elements in the [Environment] class, e.g.: Is64BitProcess, Is64BitOperatingSystem, etc.
At the prompt, I can see the list appear if I type “[Environment]::” followed by a dot. How can I fetch those values in a loop? I tried:
foreach ($item in [Environment]::) { $item }
But that fails with the “missing property name” error.
I’m actually looking for the list of fields maintained in the Environment class (e.g. CommandLine, CurrentDirectory, etc.). The complete list can be found at the first link returned from a Google search of “Environment Class”. Is that possible?
The assumption is that the OP decided it should be, since it solved his use case, or one of the moderators.
There are other ways to get this stuff, because we know PS offers many ways to do so, but what was presented was the most succinct with respect to the OP case.