Try this:
$hosts = @(
'LOCALHOST'
)
$LogFilter = @{
LogName = 'SECURITY'
ID = 4663
}
$exportar = $hosts |
ForEach-Object{
$servidor = $_
Get-WinEvent -FilterHashtable $LogFilter -ComputerName $_
ForEach-Object{
$entrada = [xml]$_.ToXml()
[PSCustomObject]@{
DATA_HORA = $entrada.event.System.TimeCreated.SystemTime
USUARIO = $entrada.Event.EventData.Data[1]."#text"
ARQUIVO = $entrada.Event.EventData.Data[6]."#text"
EventID = $entrada.Event.System.EventID
HOST = $servidor
}
} |
Where-Object {$_.USARIO -ne "SRV08$"} |
Select-Object DATA_HORA, USUARIO, ARQUIVO, @{Name = 'STATUS'; Expression = {if ($_.EventID -eq '4663') { "DELETADO" }}}
}
$data = (Get-Date -Format d) -replace "/", "-"