![xojo get list of properties in a module xojo get list of properties in a module](https://i.pinimg.com/564x/5f/8e/32/5f8e32a742d09650991df42586946c73.jpg)
Propertiesīut what if I wanted just the Id and Processname… say to eventually output to a CSV file, or to make the screen easier and quicker to read? In that case, I can do this: $p | Select-Object -Property Id,ProcessName
![xojo get list of properties in a module xojo get list of properties in a module](https://i.pinimg.com/736x/1a/22/2f/1a222f84a762c0cc9742febe264a4428.jpg)
The entire object is there, with all of it’s fields, properties, and methods, and they are all in the pipeline. Most of all, Get-Member tells me I’m working with a real object.
#XOJO GET LIST OF PROPERTIES IN A MODULE FULL#
And I can look at $info | Get-Member to see the full list of items available for use this object. I can look at $info and see a representation of that object. Now I can check $info.Length and see a number that matches the number of processes. Let’s put this data into a variable so we can look more closely: $info = $p | Select-Object -ExpandProperty StartInfo Now let’s try ExpandProperty: $p | Select-Object -ExpandProperty StartInfo This produces a bunch of a lines on the console that all have the same “” text. In this case we’ll look at selecting a single item instead of a collection, but we’ll focus on the StartInfo property, which is itself an Object with several properties of it’s own. Importantly, we see we’re working with real objects, and not something more generic that happens to have similar properties, or a bad string representation. And we can use $m | Get-Member to get the full list of properties and methods available on each object. We can also look at individual entries in $m, such $m, to get a feel for the kind of data we have now. So we see ExpandProcess rolled up the contents of the Modules collection from every object in the pipeline.
![xojo get list of properties in a module xojo get list of properties in a module](https://alwaysbusycorner.files.wordpress.com/2020/08/image.png)
On my system, I see 2931 modules, more than you’re likely to get from any one process. In fact, let’s assign them to a variable: $m = $p | Select-Object -ExpandProperty Modules These results should be much more meaningful. This will likely produce some errors (again: for processes that require admin or System access), and that’s okay we get a lot of results back, too. Now run it like this: $p | Select-Object -ExpandProperty Modules You’ll also see a bunch of blanks, where processes that require administrator or System access were just skipped. You’ll likely see a bunch of text that’s not very useful. Let’s look at that property: $p | Select-Object -Property Modules One of these is the “Modules” property, which happens to be a collection. The Get-Process cmdlet returns objects with many properties. We’ll use Get-Process throughout the examples as a data source, and for shorthand and to ensure consistent results if the system state changes, I’ll save it to a variable, like this: $p = Get-Process Collectionsįirst up are collections.
![xojo get list of properties in a module xojo get list of properties in a module](https://i.ytimg.com/vi/hHtveLxJxyQ/maxresdefault.jpg)
For best results, you’ll want to follow along in a PowerShell console on your own machine. I have four different scenarios to cover, and in each I’ll show how these two Parameters work for that situation. Select-Object accepts a number or parameters, but I would argue that Property (which is the default if no parameter name is used) and ExpandProperty are the main two, and it’s not always easy for beginners to know when to use which, or to understand why you need to do this at all. This is still a beginner-level guide, but if you find words like cmdlet and PipeLine confusing, you might want to go do a basic PowerShell tutorial first. I’m gonna share something that recently clicked for me that I think isn’t well explained elsewhere: using ExpandProperty, especially in combination with understand putting values vs Objects on the pipeline.ĮxpandProperty is part of the Select-Object cmdlet, and it’s used to expand properties into the PowerShell pipeline. I’m only an occasional PowerShell user, and therefore it’s taking some time to develop a deeper understanding of the language.