Search code examples
powershellquest

powershell quest : get-qaduser -identity guid doesn't work?


i start out by querying an exchange server 2003 with:

POSH>get-wmiobject -class Exchange_mailbox -namespace Root\MicrosoftExchangeV2 -server srv02 

to get the users. One of the properties available is the mailboxguid. so for testing, I run

POSH> get-qaduser -identity <mailboxguid> 

however it doesn't work. is there something special I need to do to the mailboxguid?

thanks in advance


Solution

  • Get-QADUser tries to resolve an object by one of these properties: DN, SID, GUID, UPN or Domain\UserName, mailboxguid is not one of them. That said, you can use the mailbox "MailboxDisplayName" property as the identity for Get-QADUser:

    get-wmiobject -class Exchange_mailbox -namespace Root\MicrosoftExchangeV2 -server srv02 | Get-QADUser -identity {$_.MailboxDisplayName}

    EDIT: Try to parse the LegacyDN WMI property if you can't use MailboxDisplayName:

    get-wmiobject -class Exchange_mailbox -namespace Root\MicrosoftExchangeV2 -computerName srv02| Get-QADUser -identity {$.LegacyDN.substring($.LegacyDN.lastIndexOf("=")+1)}

    btw, replace -server with -computerName, Get-WMIObject has no -server parameter. I addition you could go the other way and not use WMI to get mailbox enabled objects, you can query AD directly:

    Get-QADObject -sizeLimit 0 -ldap "(homeMDB=*)"