0 votes

I'm trying to build a function that will have two parameters $Containrer and $Filter
$filter - is a LDAP filer that serach some specific objects
$Containrer - is a container in which $filter should looks for object
Function shoud return list of distinguishedNames ob finded objects
So at first I try make some simple code to transform it into function but I dosn't work.

$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")
$userSAM = "%samaccountname%"
$searcher = $admService.OpenObject("Adaxes://$GroupsContainerDN", $NULL, $NULL, 0)
$searcher.SearchFilter = "(&(objectClass=group)(extensionAttribute1=$userSAM))"
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searchResults = $searcher.ExecuteSearch()
$array = @{}
foreach ($object in $searchResults.FetchAll())
$DN = $object.Properties["distinguishedName"].value
$array += $DN

The code should returned a list of DN's , but I got "You can add another hash table only to a hash table'
Seams that $DN is treated by powershell as a hash table, is it possible to workoroud it somhow?

by (510 points)

1 Answer

0 votes
by (215k points)
selected by
Best answer


You are declaring $array as a hash table, but trying to work with it as with an array. To remedy the issue, you need to declare it as an array. To do this, replace the following line:
$array = @{}
with the following:
$array = @()

Related questions

0 votes
1 answer

Hello, I need to check, from a csv file, if users exist or not. I do not have the login name but only the atributs Name givenName The output must be another csv file ... " --> False or True Is there an Adaxes script existing doing this? Thanks in advance!

asked Feb 4, 2019 by tentaal (1.1k points)
0 votes
1 answer

Hello, We did implement LAPS & Bitlocker in our AD environment. To let the helpdesk retrieve those information, we created a bunch a custom command that fetch the AD and log ... mail, but this is not possible as we have a "no password per email" policy

asked Mar 20, 2017 by Pierre (750 points)
0 votes
1 answer

I am attempting to update a business rule using PowerShell to include additional approves. This is what I have so far $account = "username" # Connect to the Adaxes ... in the second code block. Any assistance would be appreciated. (love the powershell!)

asked Oct 15, 2014 by david.towle-hilt (70 points)
0 votes
1 answer

I've the following Exchange powershell code which put ActiveSync devices in a blocked list, how to convert this to Adaxes? $DeviceIDs = Get-ActiveSyncDeviceStatistics -Mailbox $user | ... .g. import module?) so there's no need to convert scripts? Thnx Remco

asked Dec 16, 2013 by RTiel (780 points)
0 votes
0 answers

I am trying to find a way to create Groups based off an OU and a list of options (check boxes) within the portal For example: Select the Target OU to add groups ... 3 - Remote Administrators Option 3 - Remote Developers Option 4 - Readers Option 4 - Writers

asked Sep 11, 2020 by dknapp (100 points)
2,575 questions
2,318 answers
769,271 users