Export Powershell results an Excel sheet.
The below code will export to information to an excel sheet in a proper column and table format.
cls
$ToDayDate=Get-Date
$After=[datetime]::Today.AddDays(-7)
$Servers=@("RAMESH","RAMESH\UAT")
$Servers|
ForEach-Object{
$InstanceName=$_
Get-DBAErrorLog -SQLInstance $InstanceName `
-Before $ToDayDate -After $After |
Where-Object {($_.Text -like "*register a Service Principal Name (SPN)*") -or ($_.Text -like "*taking longer than*") `
-or($_.Text -like "*login failed*")
}
}|Export-Csv "C:\Users\hi\Desktop\Test\Analysis.csv" -NoTypeInformation
Comments