none
Hashtable-to-Object conversion is not supported RRS feed

  • Question

  • I am trying to export a list of all ActiveSync devices in our Office 365 tenant. I found the following script that seems to do exactly what I am wanting.

    https:  gallery.technet.microsoft.com/office/List-all-ActiveSync-e76ede25

    When this part runs

    $UserList = Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true -and -not displayname -like "CAS_{*"} | Get-Mailbox
    $UserList | foreach { Get-ActiveSyncDevice -Mailbox $_} | sort-object -property "UserDisplayName" | select-object 
    ("UserDisplayName","DeviceId","DeviceType","DeviceModel","DeviceOS","FirstSyncTime") | Export-cliXML $OutputXML

    I get this error

    Cannot process argument transformation on parameter 'Mailbox'. Cannot convert value "User Name" to type
    "Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter". Error: "Cannot convert hashtable to an object of the following type:
    Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter. Hashtable-to-Object conversion is not supported in restricted language mode or a Data section."
        + CategoryInfo          : InvalidData: (:) [Get-ActiveSyncDevice], ParameterBindin...mationException
        + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-ActiveSyncDevice
        + PSComputerName        : pod51030psh.outlook.com

    I am new to PowerShell and Office 365, so any help is appreciated.

    Friday, November 7, 2014 3:27 PM

Answers

  • Change this section

    $UserList | foreach { Get-ActiveSyncDevice -Mailbox $_}

    to this

    $UserList | foreach { Get-ActiveSyncDevice -Mailbox $_.DistinguishedName}

    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com

    • Marked as answer by Jason Cramsey Friday, November 7, 2014 10:43 PM
    Friday, November 7, 2014 7:41 PM

All replies

  • Change this section

    $UserList | foreach { Get-ActiveSyncDevice -Mailbox $_}

    to this

    $UserList | foreach { Get-ActiveSyncDevice -Mailbox $_.DistinguishedName}

    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com

    • Marked as answer by Jason Cramsey Friday, November 7, 2014 10:43 PM
    Friday, November 7, 2014 7:41 PM
  • Thanks for the update!  I tried adding the .DistinguishedName and get the same error.  I also tried replacing Get-ActiveSyncDevice with Get-MobileDevice.

    I also tried trimming the script back to the following and it does work, though not output to a summary list.

    Get-Mailbox | foreach { Get-ActiveSyncDevice -Mailbox $_.DistinguishedName}

    Friday, November 7, 2014 8:56 PM
  • Instead of distinquishedName try PrimarySmtpAddress or Alias. The -mailbox parameter is always flaky with what it wants. 

    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com

    Friday, November 7, 2014 9:05 PM
  • Adding _.DistinguishedName did work.  I just restarted my PowerShell session and ran it.  Works great!  Thanks for your help.
    Friday, November 7, 2014 10:44 PM
  • Thanks @Jason it worked for me
    Thursday, March 28, 2019 3:21 AM