Bonjour,
Je rencontre un problème sur l'envoi de données dans un mail. Je cherche à lister les fichiers d'un dossier, et à inclure cette liste format tableau dans le contenu d'un mail. Voici le code :
Code PowerShell : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 # List files on local path |Select-Object Name,LastWriteTime $list_files = Get-ChildItem $local_path_root\$DayNumber -File -Filter *.xz |Select-Object Name,LastWriteTime | Where-Object -FilterScript {($_.LastWriteTime -gt $date)} #| Format-Table Write-Host "Liste des fichiers : " $list_files #foreach( $Result += "`r`nFichiers déplacés vers $local_path_root\$DayNumber : `r`n" $Result += $list_files
Avec le code tel quel, le Write-Host affiche les fichiers sous le format :Dans le mail, elle n'apparaît pas.Liste des fichiers : @{Name=fic1.xz; LastWriteTime=11/04/2021 03:48:51} @{Name=fic2.xz; LastWriteTime=11/04/2021 03:48:53} @{Name=fic3.xz; LastWriteTime=11/04
/2021 03:48:53}
Si je décommente le format-table, j'obtiens ceci :
et ce texte est inclus dans le mail.Liste des fichiers : Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.
FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.Group
EndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData
Si j'enlève le select-object, j'ai la liste des fichiers, mais pas la date de modif
Merci pour votre aide.
Partager