Link to home
Start Free TrialLog in
Avatar of Parity123
Parity123Flag for United States of America

asked on

Powershell: Logs script assistance

Hello,

I am trying to enumerate all the event logs on a server and get 10 newest events from each log. I have something like this. I need some help with this. How do I enumerate the different logs such as System, Application, Directoryservice, FileReplication etc...

I need to replace $Logs with some dynamic code that will enumerate all the event logs on a machine.

$Logs ="System", "Application"

Foreach ($log in $logs) {
#Pull 10 newest events and store it in a file.
}

Thanks for your assistance.
Avatar of footech
footech
Flag of United States of America image

You can use Get-WinEvent -ListLog *.  A single command would be like:
Get-WinEvent -ListLog * | % { Get-WinEvent -LogName $_.logname -MaxEvents 10 }

Open in new window

Avatar of Parity123

ASKER

I am trying to get the time difference between the oldest event and the newest event and convert this into minutes, Could you please give me a hand.

$timedifference-in-minutes = newest event - oldest event
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When I am dividing current size / totalminutes I get a value output as 2.134523e-05 instead how do I get as 0.000000214 etc.