Format Conversation Data

get-help -Full about_reg* | less -i "B550410S01" -match "b\d{2}......."

 

Format Conversation Data

07/28/2012 14:11:13 John Doe: hi guys

07/28/2012 14:11:17 Jane Doh: hi

$Conversation = Get-Content C:\Scripts\Conversation.txt  $DateTimePatern = "^\d{2}/\d{2}/\d{4}\s{1}\d{2}:\d{2}:\d{2}\s{1}" $Messages =@()  foreach ($line in $Conversation) { #check if the line starts with a datestamp if ($line -match $DateTimePatern) { #Write previous line if ($Message.DateTime -ne $null) { $Messages += $Message } #Add new values $Message = {} | Select "DateTime","Person","MessageData" #Reformat Date from MM/DD/YYYY to DD/MM/YYY $Message.DateTime = ($line.substring(0,19) -replace "(\d+)/(\d+)/(\d+)", '$2/$1/$3') $Message.Person = $line.substring(20).split(":")[0] $Message.MessageData = $line.substring(20 + $Message.Person.Length + 2) } else { #add extra lines that do not begin with a datestamp to messagedata sepearate by a space $Message.MessageData += " $line" } }  $Messages | Export-Csv -NoTypeInformation C:\Scripts\Conversation.csv  #$Messages | Group-Object -Property Person | sort -desc count | select count, Name