Convert text to html format

Hi,
I have a text file & trying to convert it to html format. It’s working fine, but the data is not coming in tabular format.

Below is the script:

$SourceFile = “C:\temp\kalyan.txt”
$TargetFile = “C:\temp\kalyan.htm”

$File = Get-Content $SourceFile
$FileLine = @()
Foreach ($Line in $File) {
$MyObject = New-Object -TypeName PSObject
Add-Member -InputObject $MyObject -Type NoteProperty -Name Status -Value $Line
$FileLine += $MyObject
}
$FileLine | ConvertTo-Html -Property HealthCheck -body “Running Stausk” | Out-File $TargetFile

Can someone help me on how to get tabular format.

My text file contains below:
ServerName TimeStamp Status


Kalyan 2016-08-01T08:01:56 Running

-Kalyan

You’d have to write a custom function to turn the inputted text back into powershell objects. I suspect that you are generating the text file with powershell. If that is the case, you can build the html from wherever you got the original data from. So, how is the text file generated?

Would something like this work for you:

Import-Csv $SourceFile | Select-Object -Property * | ConvertTo-Html -Title “Running Stausk” | Out-File $TargetFile