您的位置:首页 > 移动开发

How to see all the application errors related to SQL Server and export them to a .csv file.

2012-03-15 15:05 671 查看
How to see all the application errors related to SQL Server and export them to a .csv file? Just use below command:

Get-EventLog -LogName "Application" -computername RemoteServerName | Where-Object{$_.Source -like "*SQL*"} | Where-Object {$_.EntryType -eq "Error"} | Export-Csv D:\RemoteServerName.csv

xml file:

Get-EventLog -LogName "Application" -computername RemoteServerName | Where-Object{$_.Source -like "*SQL*"} | Where-Object {$_.EntryType -eq "Error"} | Export-Clixml D:\RemoteServerName.xml

txt file:

Get-EventLog -LogName "Application" -computername RemoteServerName | Where-Object{$_.Source -like "*SQL*"} | Where-Object {$_.EntryType -eq "Error"} | Out-File D:\DBS1_sqlevents.txt

To see all SQL Server–related errors on the local or remote server:

Get-EventLog -LogName "Application" -computername PowerServer3 | Where-Object{$_.Source -like "*SQL*"} | Where-Object {$_.EntryType -eq "Error"}

Get-EventLog -LogName "Application" | Where-Object {$_.EntryType -eq "Error"} | Where-Object {($_.TimeGenerated -gt "2012/03/11") -and ($_.TimeGenerated -lt "2012/03/15")} | Sort-Object TimeGenerated -descending | Format-Table -auto

Get-EventLog -ComputerName RemoteServerName -LogName "Application" | Where-Object {$_.EntryType -eq "Error"} | Where-Object {($_.TimeGenerated -gt "20012/03/01") -and ($_.TimeGenerated -lt "2012/03/31")} | Sort-Object TimeGenerated -descending | Format-Table
–auto
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐