locked
Script invocation error RRS feed

  • Question

  • From Technet script repository for Exchange 2010 i found this script to get activesync device statistics.
    but after running below command i get error as 

    Method invocation failed because [System.Object] doesn't contain a method named 'op_Addition'.
    At line:16 char:14
    +    $Raport += <<<<  $device
        + CategoryInfo          : InvalidOperation: (op_Addition:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound

    Any suggestion where i am doing mistake.

    -----------------------------------------

    Set-AdServerSettings -ViewEntireForest $True
    Function New-Array {,$args}
    $Report = new-array
    $file_out = "D:\Scripts\mobile_devices.csv"
    $mbx = Get-CASMailbox -ResultSize Unlimited | ?{$_.HasActiveSyncDevicePartnership}
    $mbx | ForEach-Object {
     $mailbox = $_.Name
    $PrimarySMTPAddress = $([string]$_.PrimarySMTPAddress)
     $stats = Get-ActiveSyncDeviceStatistics -Mailbox $PrimarySMTPAddress
     if($stats){
      foreach ($dev in $stats){
       $device = New-Object System.Object
       $device | Add-Member -type NoteProperty -name Mailbox -value $mailbox
       $device | Add-Member -type NoteProperty -name LastSuccessSync -value $dev.LastSuccessSync
       $device | Add-Member -type NoteProperty -name DeviceID -value $([string]$dev.DeviceID)
       $device | Add-Member -type NoteProperty -name DeviceType -value $dev.DeviceType
       $device | Add-Member -type NoteProperty -name DeviceUserAgent -value $dev.DeviceUserAgent
       $device | Add-Member -type NoteProperty -name DeviceModel -value $dev.DeviceModel
       $device | Add-Member -type NoteProperty -name DeviceIMEI -value $([string]$dev.DeviceIMEI)
       $device | Add-Member -type NoteProperty -name DeviceOS -value $dev.DeviceOS
       $Raport += $device
      }
     }
    }
    $Report | Export-Csv $file_out -NoType


    -----------------------------------------

    Tuesday, November 20, 2012 1:16 PM

Answers

  • I suspect a typo at this line :

    $Raport += $device

    Rename $Raport to $Report

    Tuesday, November 20, 2012 1:26 PM