kerry_dsouza
asked on
Formatting issues while exporting to Excel within Powershell
Hi Guys,
I am trying to run the following cmdlet within powershell and it works fine, its gives me what I need but when I export it to Excel as a .xls file the output format is just horrible coz everything is in one coloumn, is there a way I can export to exel with the data in seperate coloumns?
get-wmiobject win32_bios -computer (cat c:\servers.txt) | ft __server,name,@{label='Rel ease Date';expression={$_.Conve rtToDateTi me($_.rele asedate)}} | out-file c:\server.xls
Can anyone help me out on this? Just to get the formatting correct in Excel otherwise the command let is fine!
PS: I have tried using Format-wide and most of the format cmdlets with no luck :-(
I dont want to export it as a csv file that is why I am not using the Export-Csv cmdlet
Thanks in Advance
A
win32-bios.xls
I am trying to run the following cmdlet within powershell and it works fine, its gives me what I need but when I export it to Excel as a .xls file the output format is just horrible coz everything is in one coloumn, is there a way I can export to exel with the data in seperate coloumns?
get-wmiobject win32_bios -computer (cat c:\servers.txt) | ft __server,name,@{label='Rel
Can anyone help me out on this? Just to get the formatting correct in Excel otherwise the command let is fine!
PS: I have tried using Format-wide and most of the format cmdlets with no luck :-(
I dont want to export it as a csv file that is why I am not using the Export-Csv cmdlet
Thanks in Advance
A
win32-bios.xls
If you still insist on Excel, use solutions from here:
http://pathologicalscripter.wordpress.com/out-excel/
http://pathologicalscripter.wordpress.com/out-excel/
ASKER
I did try doing the Export-csv command and the output gave me junk values....
Can I create a new object and export to excel not that I knw how to do that but just curious...
test.csv
Can I create a new object and export to excel not that I knw how to do that but just curious...
test.csv
ASKER
@soostibi --> You know I did come across that blog before posting the question here and was hoping there would be alternative solution coz I cant understand how I would use that solution!
ASKER
I tried using the code but the output I get in rather odd output.xlsx
my servers.txt has my 2 servers listed as
DXBEXCH301
DXBFILE300
test.txt
my servers.txt has my 2 servers listed as
DXBEXCH301
DXBFILE300
test.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I was initially using the "Select" cmdlet but whenever I did that I got an "IIllegal Label" error message, so I tried changing it to FT and it worked but the end result was the junk output which I have attached.
Have you tried my suggestion?
ASKER
I did actually but not before I un-installed PS V2.0 (ctp3) and installed the KB968930 and yesh if i change the ft to Select it works and I get the excel file output!! whohooo
Get-WmiObject win32_bios -computer (cat c:\server.txt) | select @{label='Server Name';expression={$_.__ser ver}},@{la bel='Bios Name';expression={$_.name} },@{label= 'Release Date';expression={$_.Conve rtToDateTi me($_.rele asedate)}} | out-excel
Is there a way we change autosave this excel to a location instead of saving it manually? since this is
invoking a function do we have to modify the function to save the file as well?
Get-WmiObject win32_bios -computer (cat c:\server.txt) | select @{label='Server Name';expression={$_.__ser
Is there a way we change autosave this excel to a location instead of saving it manually? since this is
invoking a function do we have to modify the function to save the file as well?
ASKER
Found the saving the excel file bit here --> http://pathologicalscripter.wordpress.com/about/
get-wmiobject win32_bios -computer (cat c:\servers.txt) | select-object __server,name,@{name='Rele