1..10 | % { 
    $server = ('REJK-P-SPS{0:d3}' -f $_)
    
    $folders = Get-Item -Path "\\$server\d$\ifsbodata\fsv\outgoing_notprocessed_files\*"

    $files = $folders | Where { [int]::Parse($_.Name) -ge 20161026 } | Get-ChildItem -Recurse | Where { $_.Attributes -notcontains 'directory' -and $_.Name -notmatch 'csv.gz' }

    $files | Copy-Item -Destination "\\$server\d$\ifsbodata\fsv\incoming\dcp_ud"

    Write-Host "$server - $($files.Count) copied"
}
1..6 | % { 
    $server = ('REJK-P-DPS{0:d3}' -f $_)
    
    $folders = Get-Item -Path "\\$server\d$\ifsbodata\fsv\outgoing_notprocessed_files\*"

    $files = $folders | Where { [int]::Parse($_.Name) -ge 20161026 } | Get-ChildItem -Recurse | Where { $_.Attributes -notcontains 'directory' -and $_.Name -notmatch 'csv.gz' } 

    $files | Copy-Item -Destination "\\$server\d$\ifsbodata\fsv\incoming\dcp_ud"

    Write-Host "$server - $($files.Count) copied"
}





$select = & { 
    1..10 | % { 
        $server = ('rejk-p-sps{0:d3}' -f $_)
        Write-Progress -Activity 'Scanning' -Status $server
        Get-Item "\\$server\D-Drive\IFSBOData\FSV\Outgoing_histo\20161026\FSV_HistoOutgoing.txt" | Select-String -Pattern '2016/10/26 18'
    }

    1..6 | % { 
        Write-Progress -Activity 'Scanning' -Status $server
        $server = ('rejk-p-dps{0:d3}' -f $_)
        Get-Item "\\$server\D-Drive\IFSBOData\FSV\Outgoing_histo\20161026\FSV_HistoOutgoing.txt" | Select-String -Pattern '2016/10/26 18'
    }
}


$csv = $select.line | ConvertFrom-Csv -Delimiter ';' -Header ('box name ; file name ; date of arrival ; number of retries ; date of last send info ; date of ack ; row of sending ; current date' -split ' ; ')


$csv2 = foreach($c in $csv ) {
    if($c.'date of arrival' -match '2016/10/26 18') { $c }
}


$from = (Get-Date 'October 26, 2016 18:29:50')
$to = (Get-Date 'October 26, 2016 18:54:00')
$csv3 = foreach($c in $csv2) {
    $d = [datetime]::ParseExact($c.'date of arrival'.trim(), 'yyyy/MM/dd HH/mm/ss', [cultureinfo]::InvariantCulture)

    #Write-Host "$($d.ToString('yyyy-MM-dd HH:mm:ss')) - " -NoNewline

    if($d -gt $from -and $d -lt $to) {
        $c
        #Write-Host "OK - Is between $($from.ToString('yyyy-MM-dd HH:mm:ss')) and $($to.ToString('yyyy-MM-dd HH:mm:ss'))"
    }
    else {
        #Write-Host "Not between $($from.ToString('yyyy-MM-dd HH:mm:ss')) and $($to.ToString('yyyy-MM-dd HH:mm:ss'))"
    }
}

$csv3 = $csv3 | sort 'date of arrival'