Powershell 编辑ADPropertyValueCollection(IList)

Powershell 编辑ADPropertyValueCollection(IList),powershell,Powershell,从AD中,我获得了一个变量,其中包含ADPropertyValueCollection类型以及System.Security.Cryptography.X509Certificates.X509Certificate 看起来像这样: > $test Handle Issuer Subject 1234 CA1 CN=user1 2345 CA2 CN=user2 3456 CA3

从AD中,我获得了一个变量,其中包含
ADPropertyValueCollection
类型以及
System.Security.Cryptography.X509Certificates.X509Certificate

看起来像这样:

> $test
Handle      Issuer      Subject
1234        CA1         CN=user1
2345        CA2         CN=user2
3456        CA3         CN=user3
我想从列表中删除一个位置,然后添加另一个位置。不幸的是,我不知道怎么做-我发现这是一个
IList
,它支持
Remove
方法,但似乎我不知道如何使用它

我想也许PS支持这样的东西
$test[Handle=1234]
,但显然不是这样。

通过将要删除的对象作为参数传递给它来调用,这样可以执行以下操作:

$objectToRemove = $test |Where-Object Handle -eq 1234 |Select-Object -First 1
$test.Remove($objectToRemove)