Convert gridview to xls or other?

Hi,

I have this PowershellOutput which I'd like to make an attachment of a mail. However, the output is great in gridview but can't attach that to a mail.

Please advise.

September 9th, 2015 8:26am

Hi,

You'll need to clarify what you're asking. Your email body either needs to be HTML or a s

Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 8:33am

Thanks.
I have a csv file $Report2 but the output is not in nice columns, that's actually what I 'm trying to achieve.

$Myoutput | Select-Object -PropertyComputerName,UserName,PackageName| Out-File $Report2

September 9th, 2015 9:12am

Use Export-Csv instead of Out-File.
Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 9:15am

Tried that but output is still not in columns, tried this but didn't help either

$Myoutput | Select-Object -Property ComputerName,UserName,PackageName| Export-csv $Report2 -NoTypeInformation -Delimiter ","

When I open the csv it has"ComputerName","Username","PackageName" ...

September 9th, 2015 9:33am

$mailhtml = $Myoutput | Select-Object ComputerName,UserName,PackageName |ConvertTo-Html
Send-MailMessage -BodyAsHtml -body $mailbody ....
Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 9:44am

Thanks but the data is really optimized to have it in a gridview or xls. Html would mean no sort options are avaialable anymore.
September 9th, 2015 11:04am

PowerShell does not have a grid view and email cannot display a sortable grid. Are you saying you want to convert the output to a XLS file? You have to be clear about what you are asking.

Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 11:07am

Tried that but output is still not in columns, tried this but didn't help either

$Myoutput | Select-Object -Property ComputerName,UserName,PackageName| Export-csv $Report2 -NoTypeInformation -Delimiter ","

When I open the csv it has"ComputerName","Username","PackageName"

September 9th, 2015 11:08am

$Myoutput | Select-Object -Property ComputerName,UserName,PackageName | Out-Gridview

September 9th, 2015 11:11am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics