0
Excel文件
我用以下,以節省幾個Windows服務器的事件日誌輸出的CSV文件:轉換CSV在PowerShell中
Get-EventLog -LogName $logName -ComputerName $servers -Newest 2 -Entry 'Error', 'Warning' -ErrorAction SilentlyContinue | Sort MachineName, TimeWritten | Select MachineName, Source, TimeWritten, EventID, EntryType, Message | Export-CSV $csvFile #ConvertTo-CSV #Format-Table -Wrap -Property Source, TimeWritten, EventID, EntryType, Message -Autosize |
然後我刪除了第一行(因爲它以#類型,並是不需要的):
$file = Get-Content $csvFile
$file[1..($file.length-1)] | Out-File $csvFile -Encoding ascii
當在Excel中打開,它沒有被格式化很好。我想將其轉換爲Excel並格式化單元格以適應內容,更改字體大小。
這可以從我的腳本內完成嗎?
感謝有關TypeInformation尖端,但是我正在尋找方法做的Excel格式等... – neildeadman 2012-03-29 11:59:41
@neildeadman - 增加鏈接 – manojlds 2012-03-29 12:00:17