LOG to separate CSV Files Powershell Script

No idea if anyone has a use for it. I did, so maybe I can save someone 30 minutes of time. Performance it atrocious, should have done it in Python. Alas.

Add-Type -AssemblyName System.Windows.Forms
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
    InitialDirectory = [Environment]::GetFolderPath('UserProfile')
    Filter = 'Log Files|*.log|Text Files|*.txt|All Files|*.*'
    Title = "Select Ardupilot Logfile to Split"
}
$null = $FileBrowser.ShowDialog()
$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{
    Description = "Select Output Folder (Warning: There will be many CSV files)"
}
$null = $FolderBrowser.ShowDialog()
$LogPath = $FileBrowser.FileName
$OutPath = $FolderBrowser.SelectedPath
Write-Host "That's going to take a long, long while....."
$FMTLinesReg = (Get-Content $LogPath | Select-String '(FMT,.*)') | Select-Object -Skip 1
ForEach ($item in $FMTLinesReg) {
    [array]$contentary = $null
    $LoopLine = $item.ToString()
    $LoopModuleAry = $LoopLine | Select-String -Pattern '(FMT, [0-9]+, [0-9]+, )([\w]+), ([\w]+), (.*)'
    $LoopModuleStr = $LoopModuleAry.Matches.Groups[2].Value
    $LoopLineHeader = $LoopModuleAry.Matches.Groups[4].Value
    $LoopFilePath = ($OutPath + "\" + $LoopModuleStr + ".csv")
    New-Item -Path $LoopFilePath -Type file
    Add-Content -Path $LoopFilePath -Value $LoopLineHeader
    $LoopLinesReg = Get-Content $LogPath | Select-String -Pattern "^($($LoopModuleStr), )(.*)$"
    ForEach ($item1 in $LoopLinesReg) {
        $itemtrk = $item1 | Select-String -Pattern "^($($LoopModuleStr), )(.*)$"
        $itemtrk = $itemtrk.Matches.Groups[2].Value -replace '\s+', ''
        [array]$contentary += $itemtrk
    }
    Add-Content -Path $LoopFilePath -Value ($contentary -join "`n")
}