mansoornazar
asked on
Script to export event logs in csv - entire exchnage environment
Hi,
Need a script which exports the even logs to the csv, which holds of all exchange servers ....where as am getting it a txt in below mentioned script.
Need to fetch logs only for previous day/ last 24 hrs...
-========================= ========
$ExchServer=Get-ExchangeSe rver
$Date = get-date
write-output $Date | out-file -filePath “D:\Documents and Settings\vxmano2\Desktop\o utputfile. txt” -append
-noClobber
foreach ($server in $ExchServer)
{
$version = $server.admindisplayversio n.Major
$report = Get-EventLog -logname application -newest 5 | select eventid,EntryType,source,m essage,tim egenerated
write-output $server.name | out-file -filePath “D:\Documents and Settings\vxmano2\Desktop\o utputfile. txt”
-append -noClobber
write-output $report| out-file -filePath “D:\Documents and Settings\vxmano2\Desktop\o utputfile. txt” -append -noClobber
}
======================
Need a script which exports the even logs to the csv, which holds of all exchange servers ....where as am getting it a txt in below mentioned script.
Need to fetch logs only for previous day/ last 24 hrs...
-=========================
$ExchServer=Get-ExchangeSe
$Date = get-date
write-output $Date | out-file -filePath “D:\Documents and Settings\vxmano2\Desktop\o
-noClobber
foreach ($server in $ExchServer)
{
$version = $server.admindisplayversio
$report = Get-EventLog -logname application -newest 5 | select eventid,EntryType,source,m
write-output $server.name | out-file -filePath “D:\Documents and Settings\vxmano2\Desktop\o
-append -noClobber
write-output $report| out-file -filePath “D:\Documents and Settings\vxmano2\Desktop\o
}
======================
ASKER
Am getting the errors :
A parameter cannot be found that matches parameter 'after'
and
A parameter cannot be found that matches parameter 'append'
A parameter cannot be found that matches parameter 'after'
and
A parameter cannot be found that matches parameter 'append'
I had made some changes...try now
regards
Prashanth
regards
Prashanth
$ExchServer=Get-ExchangeServer
$Date = get-date
$today = [DateTime]::Today
$today
write-output $Date | Export-Csv “D:\Documents and Settings\vxmano2\Desktop\outputfile.txt” -append -noClobber
foreach ($server in $ExchServer)
{
$version = $server.admindisplayversion.Major
$report = Get-EventLog -logname application | Where-Object {$Today -le $_.TimeWritten} | select eventid,EntryType,source,message,timegenerated
write-output $server.name | Export-Csv “D:\Documents and Settings\vxmano2\Desktop\outputfile.txt” -append -noClobber
write-output $report| Export-Csv “D:\Documents and Settings\vxmano2\Desktop\outputfile.txt” -append -noClobber
}
ASKER
thanks for responding....but getting the same error
hmmm...export-csv has limitations, working on it
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
regards
Prashanth
Open in new window