If you run a get-member on $objLdapObject does it have a properties property?
-Daniel Ratliff -----Original Message----- From: Aakash Shah [[email protected]<mailto:[email protected]>] Sent: Friday, August 09, 2013 12:00 AM Eastern Standard Time To: [email protected] Subject: [powershell] Script Not Working In PowerShell 3, But Worked in PowerShell 2 - Query Non Microsoft LDAP Server 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 The information transmitted is intended only for the person or entity to which it is addressed and may contain CONFIDENTIAL material. If you receive this material/information in error, please contact the sender and delete or destroy the material/information. ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1
