Exchange Attribute msExchRecipientTypeDetails

5.2k views Asked by At

I'm trying to get the value of msExchRecipientTypeDetails for a user using PowerShell and ADSI but I'm getting System.__ComObject.

I'm not able to move forward on getting the exact string. I'm using below PowerShell command

$ADUsr = [ADSI]"LDAP://CN=User Name,OU=OrgUnit,DC=dc,DC=dc,DC=dc"
$ADUsr.msExchRecipientTypeDetails

And result are show below

PS C:\Windows\system32> $ADUsr.msExchRecipientTypeDetails
System.__ComObject

How Can I get the exact string value? I'm expecting to get "2147483648" for UserMailbox

Any help is appreciated!

2

There are 2 answers

1
Nick On BEST ANSWER

I am able to see the value of this property if i use a directory searcher to retrieve the user object:

$Searcher = New-Object DirectoryServices.DirectorySearcher
$Searcher.Filter = "(&(objectCategory=person)(sAMAccountName=testuser))"
$Searcher.SearchRoot = 'LDAP://DC=test,DC=domain,DC=au'
$Object = $Searcher.FindOne()
$Object .Properties.msexchrecipienttypedetails

Or you can simply use the powershell cmdlet:

Get-aduser testuser -Properties msExchRecipientTypeDetails
0
TinkerAdmin On

Unfortunately, I can't use PS for AD. Tailored this to work how I wanted. I already have the user DN queried at the top of the script for another purpose

$UserDN = dsquery user forestroot -samid "USERNAME"

The rest to check for other attributes

$Searcher = New-Object DirectoryServices.DirectorySearcher
$LDAPPath = "LDAP://"+$UserDN
$Searcher.SearchRoot = $LDAPPath
$Object = $Searcher.FindOne()
$DisUsr = $Object.Properties.useraccountcontrol | Select -First 1 
$SGMembership = $Object.Properties.memberof 
$RecipientTypeDetails = $Object.Properties.msexchrecipienttypedetails | Select -First 1 
$RemoteRecipientType = $Object.Properties.msexchremoterecipienttype | Select -First 1