This is the log file I would like to be converted to csv.
------------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 4 2 4 0 0 0
Files : 17 10 17 0 0 0
Bytes : 20.0 k 5.0k 15.0 k 0 0 0
Times : 0:00:00 0:00:00 0:00:00 0:00:00
Ended : Wednesday, May 19, 2021 10:12:44 AM
The csv file can have columns like: size, date, source and destination. I will attach the code I have to get the log above. Thank you for any help!
$path = "C:\Powershell\robocopylog.txt"
If(!(test-path $path))
{
New-Item -ItemType file -Force -Path $path
}
$Logfile = "C:\Powershell\robocopylog.txt"
Clear-Content "C:\Powershell\robocopylog.txt" -Force
$EmailFrom = "email@company.com"
$EmailTo = "myemail@company.com"
$EmailBody = "Robocopy completed successfully. See attached log file for details"
$EmailSubject = "Robocopy Summary"
$files = @("data")
for($i = 0; $i -lt $files.Count; $i++){
robocopy "c:\powershell\[$i])" "c:\transferdata\[$i])" /Z /e /xx /W:5 /MAXAGE:2 /NFL /NDL /NJH /nc /np /unilog+:$Logfile
}
Send-MailMessage -To $EmailTo -from $EmailFrom -Subject $EmailSubject -Body $EmailBody -attachment $Logfile -smtpserver 192.168.249.211 -Port 25