Comments on: PowerShell: How to export Windows Eventlogs with PowerShell https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/ Cloud and Datacenter Blog focusing on Microsoft Azure Sat, 18 May 2019 14:15:51 +0000 hourly 1 https://wordpress.org/?v=6.4.1 By: Gemimah Guarneros https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-730952 Sat, 18 May 2019 14:15:51 +0000 http://www.thomasmaurer.ch/?p=2142#comment-730952 Hi
Could you please help me, I need export events from security but each one with its details for examWorkstationNameple TargetUserName,

]]>
By: TaTo https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-26394 Thu, 27 Mar 2014 16:09:38 +0000 http://www.thomasmaurer.ch/?p=2142#comment-26394 Really helpful! thanks a lot

cheers

]]>
By: Thomas Maurer https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-18533 Thu, 04 Jul 2013 18:12:38 +0000 http://www.thomasmaurer.ch/?p=2142#comment-18533 In reply to Mike.

Well here you can work with get-date and add this to a variable which you can set with the filename

]]>
By: Mike https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-18458 Sat, 29 Jun 2013 22:13:12 +0000 http://www.thomasmaurer.ch/?p=2142#comment-18458 How could I add the time stamp? I need to export the Applications and System every half hour. I don’t want the events to over write. also how do I the host name of the server so each file has hostname, date and time stamp.

]]>
By: Ansari https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-14826 Tue, 02 Apr 2013 13:05:43 +0000 http://www.thomasmaurer.ch/?p=2142#comment-14826 could it be possibe to ceck the file size before it creates a backup.
Suppose if i want to take the backup only if reacheds upto 300 MB Space

]]>
By: Marc https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-4847 Thu, 05 Jul 2012 16:49:19 +0000 http://www.thomasmaurer.ch/?p=2142#comment-4847 Thanks Thomas for the article.
@Ritchy, to read this eventlog you have to use the cmdlet get-winevent.
Try this : get-winevent -log setup

Marc.

]]>
By: Hans https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-3890 Thu, 26 Jan 2012 08:30:58 +0000 http://www.thomasmaurer.ch/?p=2142#comment-3890 Hallo Thomas,
ich versuche deine Abfrage um die EventID zu erweitern.
Leider sehe ich nicht wo der Fehler liegt:

# Config
$logFileName = “SYSTEM” # Add Name of the Logfile (System, Application, etc)
$EventID = 403
$path = “C:\Temp\” # Add Path, needs to end with a backsplash

# do not edit
$exportFileName = $logFileName + (get-date -f yyyyMMdd) + “.evt”
$logFile = Get-WmiObject Win32_NTEventlogFile | Where-Object {$_.logfilename -eq $logFileName & $_.EventID -eq $EventID}
$logFile.backupeventlog($path + $exportFileName)

]]>
By: Richy https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-3423 Tue, 01 Nov 2011 13:59:36 +0000 http://www.thomasmaurer.ch/?p=2142#comment-3423 Hi Thomas,

Thanks for the article. It helped me a lot. But I’ve got one question. I cannot export and clear the Setup eventlog on Windows Server 2008 R2. I get this error in Powershell:

You cannot call a method on a null-valued expression.
At D:\beheer\scripts\backup_setup_log.ps1:8 char:24
+ $logFile.backupeventlog <<<< ($path + $exportFileName)
+ CategoryInfo : InvalidOperation: (backupeventlog:String) [], Runti
+ FullyQualifiedErrorId : InvokeMethodOnNull

Clear-EventLog : The Log name "Setup" does not exist in the computer "localhost".
At D:\beheer\scripts\backup_setup_log.ps1:9 char:15
+ Clear-Eventlog <<<< -LogName $logFileName
+ CategoryInfo : InvalidOperation: (:) [Clear-EventLog], InvalidOper
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.ClearEventLogCommand

Do you know why I'm not able to export and clear this eventlog? All the other eventlogs (Application, Security and System) don't have this issue. Thanks in advance and with kind regards,

Richy

]]>
By: Ganesan K https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-3276 Mon, 26 Sep 2011 09:20:10 +0000 http://www.thomasmaurer.ch/?p=2142#comment-3276 Thanks for sharing a very good innovative article

]]>
By: Thomas Maurer https://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/#comment-2786 Thu, 26 May 2011 17:17:19 +0000 http://www.thomasmaurer.ch/?p=2142#comment-2786 In reply to Michel Lüscher.

yep… true this makes sence :)

]]>