Thanks for responding! I get the following error when I run “$objLdapObject |
Get-Member”:
Get-Member : The following exception occurred while retrieving members:
"Unknown error (0x8000500c)"
At D:\Projects\PowerShell\ldap\ldapsearch.ps1
+ $objLdapObject | Get-Member
+ ~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Member],
ExtendedTypeSystemException
+ FullyQualifiedErrorId :
CatchFromBaseGetMembers,Microsoft.PowerShell.Commands.GetMemberCommand
If I am running this incorrectly, please let me know. I did confirm that I see
a bunch of properties if I do this in PowerShell v2 (Server 2008r2).
In case it helps, if I check the type using “$objLdapObject.gettype()”, I see
the following in PowerShell v3:
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False DirectoryEntry
System.ComponentModel.Component
Do you have any other suggestions?
Thanks!
-Aakash Shah
From: [email protected] [mailto:[email protected]] On
Behalf Of Daniel Ratliff
Sent: Friday, August 9, 2013 2:06 AM
To: '[email protected]'
Subject: RE: [powershell] Script Not Working In PowerShell 3, But Worked in
PowerShell 2 - Query Non Microsoft LDAP Server
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]<mailto:[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
================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1