Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get rid of unrequired columns in powershell Mysql query result that appear when convert-tohtml is used

Tags:

powershell

I have this Powershell script that returns MySql query results in email.

The problem is with the required data it also prints some not rquired columns like 'RowError RowState Table ItemArray HasErrors'

enter image description here

Following is the code snippet -

$subject = "Release report - bug status"
$body = $DataSet.Tables[0] | convertto-html | out-string ;
Send-MailMessage -smtpserver $smtpserver -from $from -to $to -subject $subject -body $body -bodyashtml -priority High

How to get rid of those columns?

Pls help.

like image 572
SoftwareTestingEnthusiast Avatar asked Feb 11 '23 01:02

SoftwareTestingEnthusiast


1 Answers

You should be able to simply select the data from your table that you do want when defining $body.

$body = $DataSet.Tables[0] | Select bug_id,Status,Resolution,Summary,Deadline | convertto-html | out-string

Or, you can select everything, and then specify what you want to exclude:

$body = $DataSet.Tables[0] | Select * -ExcludeProperty RowError, RowState, Table, ItemArray, HasErrors | convertto-html | out-string
like image 61
TheMadTechnician Avatar answered May 12 '23 08:05

TheMadTechnician