Using this code I have found on the internet, I forget from where so I do not know whom to aknowledge for the source, I can connect to a Directory Server that is Novell e-Directory. Now I can initially pull some data but I seem to not have all of the understanding of the code.
#Setup Modules
Import-Module ActiveDirectory
Add-Type -AssemblyName System.DirectoryServices
#Setup eDirectory Connection Variables
$eDirPath = ‘LDAP://(IPADDRESS)/o=ROOT’
$eDirUser = ‘’
$eDirPWD = ‘’
$eDirAuthType = ‘None’
#Establish eDirectory Connection and Enumerate
$Root = New-Object System.DirectoryServices.DirectoryEntry -argumentlist $eDirPath,$eDirUser,$eDirPWD,$eDIrAuthType
$Query = New-Object System.DirectoryServices.DirectorySearcher
$Query.SearchRoot = $Root
$Query.Filter = “(ObjectClass=Person)”
$SearchResults = $Query.FindAll()
$edirUserArray = @()
foreach ($Result in $SearchResults){
$eDirObject = [PSCustomObject]$Result.Properties
$edirUserArray += $eDirObject
}
Now I can list contents of the array but cannot seem figure out how to filter the results or even get the values of the properties that I have collected.
For example I want to find all accounts with an “employeeStatus” of a certain value.
I have tried this code to list the employee status of all objects but only get a blank screen in return. I think this could be that not all items in the array will have an employee status.
foreach ($i in $edirUserArray){
if($i.employeestatus){
write-host $i
}
The goal of my question here is I need to be able to query e-directory for items and eventually perform an action against those items utilizing PowerShell. Such as find user that has not logged on for 60 days and then compile a list for deletion. This list will be scrubbed manually first for known accounts and then another powershell command to go through scrubbed list to delete objects in e-directory.
Any help would be appreciated.
Thank you.
}