Powershell how to sum time

Viewed 1550

I am running a Get-MailboxImportRequestStatistics script to pull the OverallDuration for each PST imported. I am trying to then sum them using the measure-object -sum but keep getting "measure : Input object "00:03:00.4321755" is not numeric." I assume I have to format the output?

$mbxreqs = Get-MailboxImportRequest -BatchName csr2 | where {$_.status -eq "Completed"}

    $TimeCollection =@()
    foreach ($mbx in $mbxreqs) {
    $mbxstat = Get-MailboxImportRequestStatistics -Identity $mbx.RequestGuid | Select-Object @{L="MigTime";E={$_.OverallDuration}}

    $result = New-Object psobject
    $result | Add-Member -MemberType NoteProperty -Name "MigTime" -Value $mbxstat.migtime
    $TimeCollection += $result
    }

    ($TimeCollection | measure -property migtime -sum).sum
1 Answers
Related