I have two different objects in Powershell:
One is using a
"Project"class instantiated withNew-Object. Each of these contain 2properties.The second one is just an array of strings.
Now, I would like to remove the projects in the array of Project that are not in the second array.
For, instance. In Linq, I would do something like this:
var result = from item in arrayOfStrings
from project in arrayOfProjects
where project.Property2 == item
select project;
This query would get me anything in the first list that is not in the second one.
What I have tried without success:
$result = $projects | Where-Object { $_.Property2 -eq $arrayOfStrings | Select-Object }
Thank you
Edit
The class looks like this:
public class Project
{
public string Name {get; set;}
public string Guid {get; set;}
}
The second array is just filled with some Guids. I want to get a $queryResult with the Projects that are in the second array.
Select-Object, thereWhere-Objectwill do the "select"$projects | Where-Object Property2 -in $arrayOfStrings