1 2 3 4 5 6 7 8 9 10 11 12
| $dossier = "C:\Mon dossier"
$last_n_line = 3
Get-ChildItem -Path "${dossier}\*\*\*.txt" -Force -File |
Where-Object {$_.FullName -match '\\\d{4}\\\d{2}\\.+\d{6}\.txt$'} |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1 |
ForEach-Object {
$lines= $_ | Get-Content | Select-Object -Last $last_n_line
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
$null = [System.Windows.Forms.MessageBox]::Show(($lines -join "`n"), "titre", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Exclamation)
} |
Partager