Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Powershell system-object – select property with "filter"

Lets say I have an object named something:

Name                                           : name1
Group                                          : group1

Name                                           : name2
Group                                          : group2

Name                                           : name3
Group                                          : group1

I can access all names by:

$something | Select -ExpandProperty "Name";

it returns: name1 name2 name3

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How would I select only the names from group1?
so it returns

name1 name3

Something like:

$something | Select -ExpandProperty "Name" -Where [Group -eq 'group1'];

>Solution :

Use the Where-Object cmdlet to filter:

$something |Where-Object Group -eq 'group1' |Select -ExpandProperty "Name"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading