The above gives:
PS C:\EndurAutomation\powershell\bin> C:\EndurAutomation\powershell\bin\ets_update_constring.ps1 Exception calling "FindAll" with "0" argument(s): "An operations error occurred. " At C:\EndurAutomation\powershell\bin\ets_update_constring.ps1:20 char:30 + $result = $ldapSearch.FindAll <<<< () + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
$ldapDN = "dc=<masked>,dc=<masked>"
$ldapURI = "ldap://<masked>/$ldapDN"
$env = "sqlplus -S <masked> ``@env.sql > env.list"
Invoke-Expression $env
$envData = (Get-Content "env.list")
$envFilter = "(|"
foreach ($env in $envData) {
$envFilter += "(cn=$env)"
}
$envFilter += ")"
$ldapEntry = New-Object System.DirectoryServices.DirectoryEntry($ldapUR, $null, $null, [System.DirectoryServices.AuthenticationTypes]::Anonymous)
$ldapSearch = New-Object System.DirectoryServices.DirectorySearcher($ldapEntry)
$ldapSearch.PageSize = 1000
$ldapSearch.Filter = $envFilter
$result = $ldapSearch.FindAll($envFilter)