Ciao
Il codice iniziale è
$startdate = (get-date) - (new-timespan -Hours 12)
$events =Get-EventLog "Application" |
Select-Object Source,EntryType, Message, TimeGenerated |
Where-Object {($_.Source -eq "VMM Custom Event")-and($_.timegenerated -gt $startdate ) -and ($_.EntryType -eq "Error" )}
e come dicevo ho notato che non sembra funzionare correttamente.
Quello modificato è:
$events =Get-EventLog "Application" |
Select-Object Source,EntryType, Message, TimeGenerated |
Where-Object {($_.TimeGenerated -gt $startdate )}
#and delle 3 condizioni non sembra funzionare, conflitto data e source,
#risolta estraendo le piu recenti e poi considerando quelle della virtualizzazione
#Where-Object {($_.Source -eq "VMM Custom Event")-and($_.timegenerated -gt $startdate ) -and ($_.EntryType -eq "Error" )}
$allevents = @()
for ( $i = 0 ; $i -lt $events.Count; $i++ )
{
if(($events[$i].Source -eq "VMM Custom Event"))
{
$allevents+= $events[$i]
}
}
Di seguito un'estratto della mail che genero e contiene gli eventi estratti
Source EntryType Message TimeGenerated
VMM Custom Event Information The P2V Conversion xxx_V_1 was successful. 07/03/2010 11:21:44
VMM Custom Event Information The P2V Conversion xxx_V_1 was successful. 07/03/2010 11:20:26
Grazie