So I'm trying to Autosize the columns, so that when I open up the excel file, I dont have to expand the columns manually to see all the contents inside the cell. But for some reason , I'm failing, even the .xls file shows everything in one column instead of multiple columns. This is wht I did for the script, if anyone can help that would be great!
$excel = New-Object -ComObject excel.application;
$excel.visible=$false;
$serverInfoSheet= $excel.Workbooks.Open("C:\Temp\report.csv");
$serverInfoSheet.Activesheet.Cells.EntireColumn.Autofit();
$serverInfoSheet.SaveAs("C:\Temp\report.xls");
$ServerInfoSheet.Close(0);
$excel.Quit();