Search code examples
powershellpipelinegroup-policy

Powershell Newbie: How do I filter results so that only the information I get back can be used in a pipeline?


Lets say I run a powershell command (in my case Group Policy related) but lets say I run this command:

PS C:>Get-GPO -All

and my output looks like:

DisplayName : My Named GPO

DomainName : mydomain.com

Owner : Domain Admins

Id : Random_GUID ...

How can I "filter" that command so that it only returns the lines relating to DisplayName? Is that possible or will I need to do some string parsing that's not available inside a pipeline operation? Because ultimately, I'm looking to use that DisplayName param to pipe to another command.

Thanks in advance!


Solution

  • You can use Select-Object (or select in short)

    Get-GPO -All | Select DisplayName