Hello! I have a PowerShell script that queries a non Microsoft LDAP server and
outputs the results (it returns the various attributes for the user). This
code worked perfectly fine in PowerShell v2 (on Windows 7 and Server 2008r2),
but in PowerShell v3 (on Windows 8), I get an error message that I am not sure
how to fix:
format-default : Unknown error (0x8000500c)
+ CategoryInfo : NotSpecified: (:) [format-default], COMException
+ FullyQualifiedErrorId :
System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.FormatDefaultCommand
Here is the code I am running:
$strLdapServer = "ldap.domain.com" # ldap server name changed to generic name
$strLdapBaseDN = "some base DN" # base DN entered here
$authLdap = [System.DirectoryServices.AuthenticationTypes]::Anonymous
$strUsername = "username"
$strLdapSearchPath = "LDAP://" + $strLdapServer + "/uid=" + $strUsername + ","
+ $strLdapBaseDN
$objLdapObject = New-Object
System.DirectoryServices.DirectoryEntry($strLdapSearchPath,$null,$null,$authLdap)
$objLdapObject.Properties
Although the error doesn't state the line number, the error is occurring on the
last line "$objLdapObject.Properties" (if I comment it out, it does not produce
any error messages).
If there is a better/easier way to query a non Microsoft LDAP server in
PowerShell v3, please let me know.
If there is any other information that I missed, please let me know.
Thanks!
-Aakash Shah
================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1