Skip to content
Code2
ultratrailrunningags_g7wnyd
2025-06-03T11:28:35-06:00
Copy to Clipboard
# Ruta del archivo CSV $csvPath = "C:\Logs\SharedFolderAccess.csv" # Crear CSV si no existe if (-not (Test-Path $csvPath)) { "Fecha,Usuario,Archivo,Accion" | Out-File -FilePath $csvPath -Encoding UTF8 } # Bucle continuo while ($true) { # Buscar eventos recientes con ID 560 (acceso a objeto en Windows Server 2003) $eventos = Get-EventLog -LogName Security -Newest 100 | Where-Object { $_.EventID -eq 560 -and $_.TimeGenerated -gt (Get-Date).AddSeconds(-10) } foreach ($evento in $eventos) { $fecha = $evento.TimeGenerated.ToString("yyyy-MM-dd HH:mm:ss") $mensaje = $evento.Message # Extraer Usuario if ($mensaje -match "User Name:\s+(.*)") { $usuario = $matches[1].Trim() } else { $usuario = "Desconocido" } # Extraer Nombre de archivo accedido if ($mensaje -match "Object Name:\s+(.*)") { $archivo = $matches[1].Trim() } else { $archivo = "Desconocido" } # Extraer tipo de operación (Accesses) if ($mensaje -match "Accesses:\s+(.*)") { $accion = $matches[1].Trim() } else { $accion = "Desconocido" } # Guardar en CSV "$fecha,$usuario,$archivo,$accion" | Out-File -FilePath $csvPath -Append -Encoding UTF8 } Start-Sleep -Seconds 10 }
Page load link
Go to Top