# encoding: ascii
# api: powershell
# title: custompsobjectexampleexp
# description: Custompsobject
# version: 0.1
# author: redyey
# license: CC0
# x-poshcode-id: 5646
# x-archived: 2015-02-17T23:36:29
# x-published: 2015-12-15T16:45:00
#
#
$AllValues = @()
$Values = @()

$Migrations = Get-MoveRequest

foreach ($Migration in $Migrations) 
{
    $Values = Get-MoveRequestStatistics $Migration.alias -IncludeReport | Select-Object displayname,status,starttimestamp,completiontimestamp,overallduration,totalmailboxsize,totalmailboxitemcount

    $NewObject = [pscustomobject]@{
        Displayname = $Values.Displayname
        Status = $Values.Status
        StartTimeStamp = $Values.StartTimeStamp
        CompletionTimeStamp = $Values.Completiontimestamp
        OverallDuration = $Values.OverallDuration
        TotalMailboxSize = $Values.TotalMailBoxSize
        TotalMailboxItemCount = $Values.TotalMailboxItemCount
    }
    $Allvalues += $NewObject
}

$AllValues | Export-Csv -Delimiter ';' -NoTypeInformation -Force -Path 'C:\Users\Tester\Desktop\Migrationstats.csv'
