Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Store Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems.

Go Back   Vista Forums > Vista technology newsgroups > PowerShell

Using PowerShell to handle Eventlog

Reply
 
Thread Tools Display Modes
Old 04-15-2008   #1 (permalink)
Florian
Guest
 
Posts: n/a

Using PowerShell to handle Eventlog

Hello,
my idea is as follows (basically to play & learn with Powershell):

* Running a daily powershellscript at night which:
** Exports all entries in a file
** Delete all entries

Ok i could use somethnig like this to list all System-Event Entries
and write them to log:
Quote:
Quote:

>> Get-Eventlog system | Format-List | out-file -encoding ASCII -filepath output2.txt
or
Quote:
Quote:

>> Get-Eventlog system -newest 10 | Format-List | out-file -encoding ASCII -filepath output2.txt
to have only the latest

Now i am asking myself howto delete all entries in the second step.

any ideas how to handle this ?


Best regards
fidel
  Reply With Quote

Old 04-15-2008   #2 (permalink)
Fidel
Guest
 
Posts: n/a

Re: Using PowerShell to handle Eventlog

Ok,

i can use this:
Quote:
Quote:

>> get-eventlog system | Format-List | out-file -encoding ASCII -filepath foobar.txt
to dump all system-related informations in my text file


and i can use this:
Quote:
Quote:

>> get-eventlog -list |%{$_.clear()}
to delete the event logs completly


Now regarding the filename:
--
i.e.
i would like to end with files like that:
* 20080415_hostname_logtype.txt (execution_date + hostname + here:
system


Best regards
fidel




  Reply With Quote
Old 04-15-2008   #3 (permalink)
Marco Shaw [MVP]
Guest
 
Posts: n/a

Re: Using PowerShell to handle Eventlog

Quote:

> Now i am asking myself howto delete all entries in the second step.
>
> any ideas how to handle this ?
I am not aware of any way that you can selectively delete entries like
this. You can export your entire log, parse the export, delete the
entries you want, then re-import it. But... This method can only be
re-imported, to my knowledge, to a *new* log name, and can't be
re-imported into the default/original log. For example, I can't export
the Security log, delete it, then re-import what I just exported back to
the Security log.

I wouldn't start editing the binary log either...

Marco
  Reply With Quote
 
Reply

Thread Tools
Display Modes









Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48