Wiki di Michele

Registri eventi: Get-WinEvent

GuidaUltima modifica: 24/10/2026 Verificata il 24/10/2026

Get-WinEvent legge i registri eventi di Windows (Applicazione, Sistema, Sicurezza e quelli specifici dei servizi). Sostituisce il vecchio Get-EventLog.

Elencare i registri

Get-WinEvent -ListLog *
Get-WinEvent -ListLog * | Where-Object RecordCount -gt 0 | Sort-Object RecordCount -Descending | Select-Object -First 10 LogName, RecordCount
Get-WinEvent -ListLog Application, System, Security

Leggere gli eventi

Get-WinEvent -LogName System -MaxEvents 20
Get-WinEvent -LogName Application -MaxEvents 50 | Format-Table TimeCreated, Id, LevelDisplayName, Message -AutoSize
Get-WinEvent -LogName System -Oldest -MaxEvents 5

Il registro Security richiede una console amministratore.

Filtrare con FilterHashtable

Il metodo corretto e veloce: il filtro viene applicato dal sistema, non da PowerShell.

Get-WinEvent -FilterHashtable @{LogName='System'; Level=2}
Get-WinEvent -FilterHashtable @{LogName='System'; Level=1,2,3; StartTime=(Get-Date).AddHours(-24)}
Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Application Error'}
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625; StartTime=(Get-Date).AddDays(-1)}
Get-WinEvent -FilterHashtable @{LogName='System'; Id=6005,6006,6008,41}
ChiaveSignificato
LogNameNome del registro
ProviderNameOrigine dell'evento
IdIdentificativo evento (singolo o elenco)
LevelGravità: 1 Critico, 2 Errore, 3 Avviso, 4 Informazioni, 5 Dettagliato
StartTime / EndTimeIntervallo di tempo
KeywordsParole chiave (es. 4503599627370496 per audit fallito)

Non usare Where-Object su registri grandi quando puoi usare -FilterHashtable: la differenza è di ordini di grandezza.

Eventi utili da conoscere

IDRegistroSignificato
4624SecurityAccesso riuscito
4625SecurityAccesso fallito
4634 / 4647SecurityDisconnessione
4672SecurityAccesso con privilegi speciali
4720SecurityAccount utente creato
4726SecurityAccount utente eliminato
4740SecurityAccount bloccato
6005 / 6006SystemAvvio / arresto del servizio registro eventi
6008SystemArresto imprevisto
41SystemKernel-Power: riavvio senza arresto corretto
1074SystemArresto o riavvio avviato da un utente o processo
7034 / 7036SystemServizio terminato inaspettatamente / cambio stato
1000ApplicationArresto anomalo di un'applicazione

Esempi pratici

Tentativi di accesso falliti nelle ultime 24 ore:

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625; StartTime=(Get-Date).AddDays(-1)} |
  ForEach-Object {
    [pscustomobject]@{
      Ora = $_.TimeCreated
      Utente = $_.Properties[5].Value
      IP = $_.Properties[19].Value
    }
  }

Chi ha riavviato il computer:

Get-WinEvent -FilterHashtable @{LogName='System'; Id=1074} -MaxEvents 5 | Select-Object TimeCreated, Message

Ultimo avvio del sistema:

(Get-CimInstance Win32_OperatingSystem).LastBootUpTime

Cercare un testo nel messaggio

Get-WinEvent -LogName System -MaxEvents 1000 | Where-Object Message -like "*disk*"

Esportare

Get-WinEvent -LogName System -MaxEvents 100 | Select-Object TimeCreated, Id, LevelDisplayName, Message | Export-Csv .\eventi.csv -NoTypeInformation -Encoding UTF8
wevtutil epl System C:\Backup\system.evtx

Registri di altri computer

Get-WinEvent -ComputerName SERVER01 -LogName System -MaxEvents 20

Nota su Get-EventLog

Get-EventLog -LogName System -Newest 10 funziona solo in Windows PowerShell 5.1 e non legge i registri moderni. Usa Get-WinEvent.

Tag

comandipowershellwindows

Altre pubblicazioni in questa sezione

Suggerisci una correzione