powershell - Error calling PutEx with a filtered array -


if call putex on adsi object in powershell works expected:

$values = @("xyz", "abc" ) $user = [adsi]"ldap://cn=someone,cn=users,dc=acme,dc=com" $user.putex($ads_property_delete, "altsecurityidentities", $values) $user.setinfo() 

howver, if same thing filtering values where-object, error:

$values = @("xyz", "abc" ) $filtered = @($values | ? { $_.startswith("x") }) $user = [adsi]"ldap://cn=someone,cn=users,dc=acme,dc=com" $user.putex($ads_property_delete, "altsecurityidentities", $filtered) $user.setinfo() 

the error is: exception calling "putex" "3" argument(s): "unspecified error.

what's difference in 2 cases?

what if try iterate through $filtered objects follows:

$values = @("xyz", "abc" ) $filtered = @($values | ? { $_.startswith("x") }) foreach($item in $filtered){     $user = [adsi]"ldap://cn=someone,cn=users,dc=acme,dc=com"     $user.putex($ads_property_delete, "altsecurityidentities", $item)     $user.setinfo() } 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -