Lassen sich diese Events einfach in ein anderes Event schreiben, dass ich angelegt habe ?
Ziel ist es die Event 5156 zu sichern, allerdings in eine gemeinsames Protokoll, dass ich ebenfalls nach Größe löschen kann.
Meine Idee wäre hier folgende:
cls
$message = Get-EventLog "Security" -newest 100 | Where-Object {$_.EventID -eq 5157} | Format-List -property "Message"
$message.ToString()
echo $message
$evt=new-object System.Diagnostics.EventLog("Application")
$evt.Source="MyEvent"
$infoevent=[System.Diagnostics.EventLogEntryType]::Information
$evt.WriteEntry($message,$infoevent,70)
Leider beomme ich auch hier einen Fehler. Die Variable Message wird wie folgt später im Eventlog angezeigt:
Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData
Daraufhin habe ich versucht das array einfach zu konvertieren. was mir allerdings nicht gelingt .... Hier mein QUelltext
cls
[array]$message = Get-EventLog "Security" -newest 100 | Where-Object {$_.EventID -eq 5157} | Format-List -property "Message"
$test=[String]
for ($i=0; $i -le $message.Length – 1; $i++){
$test = $test + $message[$i]
}
echo $test
$evt=new-object System.Diagnostics.EventLog("Application")
$evt.Source="MyEvent"
$infoevent=[System.Diagnostics.EventLogEntryType]::Information
$evt.WriteEntry($message ,$infoevent,70)
Danke vorab