function global:r8() { #this defines our user color coding: #suggest the following: #put your user first and make it cyan, which is blue like the background #valid choices for color are: Green, DarkGreen, Red, DarkRed, Blue (careful Blue is the background color), DarkBlue, Cyan, DarkCyan, Magenta, DarkMagenta, Yellow, DarkYellow, white, Gray, DarkGray, Black $csv = @" name,color basementjack/jack8V2,cyan BobLoblaw,green JB,yellow Pacific,magenta "@ #this is just powershells way of converting our CSV raw data into an object we can search later. $colors= convertfrom-csv $csv #set the run8 log file name and location: $file = 'C:\Run8Studios\Run8 Train Simulator V2\Run8.log' #import the contents of the run8 log, # | Where the lines match the pattern seen by conversations $contents = get-content $file | where {$_ -like "* INFO - 0: *"} # Note: The two spaces at the end of the like clause filter out people coming and going. foreach ($line in $($contents | where {$_ -notlike "* INFO - 0: *"})) { $parts = $line.split(":") #skip these AI recrew messages: if ($parts[4] -eq " Hey guess what... I just AI-Recrewed a train!") {continue} #find the color from our colortable for the given user name: $color = $($colors | where {$_.name -eq $parts[3].trim().split(" ")[0]}).color #fallback on the default color if user not found if ($color -eq $null) { $color = "Gray"} #output the log entry in the desired color: write-host $line -foregroundcolor $color } } write-host "function loaded into memory, type r8 [enter] to see the conversation history"