how to query list in powershell

Posted by Varyanica on Stack Overflow See other posts from Stack Overflow or by Varyanica
Published on 2010-05-19T22:40:42Z Indexed on 2010/05/19 23:10 UTC
Read the original article Hit count: 191

Filed under:
|
add-type -Language CSharpVersion3 -TypeDefinition @"
    public class pack_code
    {
        public pack_code() {}

        public string code { get; set; }
        public string type { get; set; }
    }
"@

$a = New-Object pack_code
$a.code = "3"
$a.type = "5"
$b = New-Object pack_code
$b.code = "2"
$b.type = "5"
$c = New-Object pack_code
$c.code = "2"
$c.type = "5"
$d = New-Object pack_code
$d.code = "1"
$d.type = "1"

$codes = New-Object 'System.Collections.Generic.List[object]'
$codes.add($a)
$codes.add($b)
$codes.add($c)
$codes.add($d)

is there a way to select distinct from $codes and select the objects where type equals 1? How can i use linq with PowerShell?

© Stack Overflow or respective owner

Related posts about powershell

Related posts about LINQ