Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 help and support Forum Windows 8 Forum Vista Tutorials

Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Newsgroup Archive > Misc Newsgroups > PowerShell

Vista - Using PowerShell to handle Eventlog


 
 
04-15-2008   #1 (permalink)
Florian


 

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
My System SpecsSystem Spec
04-15-2008   #2 (permalink)
Fidel


 

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




My System SpecsSystem Spec
04-15-2008   #3 (permalink)
Marco Shaw [MVP]


 

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
My System SpecsSystem Spec
 

Using PowerShell to handle Eventlog problems?



Thread Tools


Similar topics to: Using PowerShell to handle Eventlog
Thread Forum
get-eventlog PowerShell
Easy to get handle from listbox. How to get listbox from handle? .NET General
Can Powershell handle COM events? PowerShell
Get-eventlog PowerShell
Control.Handle - How do I get a handle to a control with WinFX Avalon


Vista Forums 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 Ltd

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 49 50