Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Log Parser - Plain, COM, .NET

Closed Thread
 
Thread Tools Display Modes
Old 03-29-2007   #1 (permalink)
Flowering Weeds
Guest


 

Log Parser - Plain, COM, .NET



First the plain Log Parser version.

Windows PowerShell
Copyright (C) 2006 Microsoft Corporation. All rights reserved.

PS> LogParser "SELECT text FROM '$pshome\default.help.txt' WHERE text
LIKE '%get
-help%'" -i:textword -statsff
Text
----------
Get-Help
get-help
"Get-help"
get-help
get-help
get-help
get-help
get-help
get-help
get-help
PS>

Next the COM Log Parser version.

Windows PowerShell
Copyright (C) 2006 Microsoft Corporation. All rights reserved.

PS> $lpTextwordInputFormat = new-object -com
"MSUtil.LogQuery.TextWordInputFormat"

PS> $lpNativeOutputFormat = new-object -com
"MSUtil.LogQuery.NativeOutputFormat"

PS> $lpQueryObject = new-object -com "MSUtil.LogQuery"

PS> $null = $lpQueryObject.ExecuteBatch("SELECT text FROM
'$pshome\default.help.txt' WHERE text LIKE '%get-help%'",
$lpTextwordInputFormat,
$lpNativeOutputFormat)
Text
----------
Get-Help
get-help
"Get-help"
get-help
get-help
get-help
get-help
get-help
get-help
get-help
Ps>

Execute query and receive a LogRecordSet.

PS> $recordSet = $lpQueryObject.Execute("SELECT text FROM
'$pshome\default.help.txt' WHERE text LIKE '%get-help%'",
$lpTextwordInputFormat)
PS> do {
>> $record = $recordSet.GetRecord()
>> $record.GetValue(0)
>> $recordSet.MoveNext()
>> } while ($recordSet.atEnd() -eq $false)
>>

Get-Help
get-help
"Get-help"
get-help
get-help
get-help
get-help
get-help
get-help
get-help
PS>

Next the .Net Log Parser version.

Windows PowerShell
Copyright (C) 2006 Microsoft Corporation. All rights reserved.

PS> [system.reflection.assembly]::Loadfile("C:\Program Files\Log
Parser 2.2\Interop.MSUtil.dll")

GAC Version Location
--- ------- --------
False v1.1.4322 C:\Program Files\Log Parser
2.2\Interop.MSUtil.dll

PS> $lpTextwordInputFormat = new-object
Interop.MSUtil.COMTextWordInputContextClassClass

PS> $lpNativeOutputFormat = new-object
Interop.MSUtil.COMNativeOutputContextClassClass

PS> $lpQueryObject = new-object Interop.MSUtil.LogQueryClassClass

PS> $null = $lpQueryObject.ExecuteBatch("SELECT text FROM
'$pshome\default.help.txt' WHERE text LIKE '%get-help%'",
$lpTextwordInputFormat, $lpNativeOutputFormat)
Text
----------
Get-Help
get-help
"Get-help"
get-help
get-help
get-help
get-help
get-help
get-help
get-help
PS>

All done showing all three plain, COM,
and .NET Log Parser 2.2 query versions.




Old 03-29-2007   #2 (permalink)
Rob Campbell
Guest


 

RE: Log Parser - Plain, COM, .NET

Thank you.

"Flowering Weeds" wrote:

>
>
> First the plain Log Parser version.
>
> Windows PowerShell
> Copyright (C) 2006 Microsoft Corporation. All rights reserved.
>
> PS> LogParser "SELECT text FROM '$pshome\default.help.txt' WHERE text
> LIKE '%get
> -help%'" -i:textword -statsff
> Text
> ----------
> Get-Help
> get-help
> "Get-help"
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help
> PS>
>
> Next the COM Log Parser version.
>
> Windows PowerShell
> Copyright (C) 2006 Microsoft Corporation. All rights reserved.
>
> PS> $lpTextwordInputFormat = new-object -com
> "MSUtil.LogQuery.TextWordInputFormat"
>
> PS> $lpNativeOutputFormat = new-object -com
> "MSUtil.LogQuery.NativeOutputFormat"
>
> PS> $lpQueryObject = new-object -com "MSUtil.LogQuery"
>
> PS> $null = $lpQueryObject.ExecuteBatch("SELECT text FROM
> '$pshome\default.help.txt' WHERE text LIKE '%get-help%'",
> $lpTextwordInputFormat,
> $lpNativeOutputFormat)
> Text
> ----------
> Get-Help
> get-help
> "Get-help"
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help
> Ps>
>
> Execute query and receive a LogRecordSet.
>
> PS> $recordSet = $lpQueryObject.Execute("SELECT text FROM
> '$pshome\default.help.txt' WHERE text LIKE '%get-help%'",
> $lpTextwordInputFormat)
> PS> do {
> >> $record = $recordSet.GetRecord()
> >> $record.GetValue(0)
> >> $recordSet.MoveNext()
> >> } while ($recordSet.atEnd() -eq $false)
> >>

> Get-Help
> get-help
> "Get-help"
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help
> PS>
>
> Next the .Net Log Parser version.
>
> Windows PowerShell
> Copyright (C) 2006 Microsoft Corporation. All rights reserved.
>
> PS> [system.reflection.assembly]::Loadfile("C:\Program Files\Log
> Parser 2.2\Interop.MSUtil.dll")
>
> GAC Version Location
> --- ------- --------
> False v1.1.4322 C:\Program Files\Log Parser
> 2.2\Interop.MSUtil.dll
>
> PS> $lpTextwordInputFormat = new-object
> Interop.MSUtil.COMTextWordInputContextClassClass
>
> PS> $lpNativeOutputFormat = new-object
> Interop.MSUtil.COMNativeOutputContextClassClass
>
> PS> $lpQueryObject = new-object Interop.MSUtil.LogQueryClassClass
>
> PS> $null = $lpQueryObject.ExecuteBatch("SELECT text FROM
> '$pshome\default.help.txt' WHERE text LIKE '%get-help%'",
> $lpTextwordInputFormat, $lpNativeOutputFormat)
> Text
> ----------
> Get-Help
> get-help
> "Get-help"
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help
> PS>
>
> All done showing all three plain, COM,
> and .NET Log Parser 2.2 query versions.
>
>
>
>
>

Old 03-30-2007   #3 (permalink)
Jacques Barathon [MS]
Guest


 

Re: Log Parser - Plain, COM, .NET

"Flowering Weeds" <floweringnoweedsno@hotmail.com> wrote in message
news:%23qU43NkcHHA.2268@TK2MSFTNGP02.phx.gbl...
>
>
> First the plain Log Parser version.
>
> Windows PowerShell
> Copyright (C) 2006 Microsoft Corporation. All rights reserved.
>
> PS> LogParser "SELECT text FROM '$pshome\default.help.txt' WHERE text
> LIKE '%get
> -help%'" -i:textword -statsff
> Text
> ----------
> Get-Help
> get-help
> "Get-help"
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help
> get-help


And finally a plain native PowerShell version :-) :

PS> type $pshome\en-us\default.help.txt | ?{$_ -match "(\S*get-help\S*)"} |
%{$matches[0]}

Jacques

Old 03-30-2007   #4 (permalink)
Rob Campbell
Guest


 

Re: Log Parser - Plain, COM, .NET

If I was just processing text, I wouldn't user LogParser.

What I'm after is a function that will read a saved Windows Event Log file,
and return a custom PS object that approximates the eventlogentry object
well enough that a script written to work with the properties of one has a
reasonable chance of working with the other.

If anyone has a better idea of how best to get PowerShell to work with saved
event logs, I'm open to suggestions.

"Jacques Barathon [MS]" wrote:

> "Flowering Weeds" <floweringnoweedsno@hotmail.com> wrote in message
> news:%23qU43NkcHHA.2268@TK2MSFTNGP02.phx.gbl...
> >
> >
> > First the plain Log Parser version.
> >
> > Windows PowerShell
> > Copyright (C) 2006 Microsoft Corporation. All rights reserved.
> >
> > PS> LogParser "SELECT text FROM '$pshome\default.help.txt' WHERE text
> > LIKE '%get
> > -help%'" -i:textword -statsff
> > Text
> > ----------
> > Get-Help
> > get-help
> > "Get-help"
> > get-help
> > get-help
> > get-help
> > get-help
> > get-help
> > get-help
> > get-help

>
> And finally a plain native PowerShell version :-) :
>
> PS> type $pshome\en-us\default.help.txt | ?{$_ -match "(\S*get-help\S*)"} |
> %{$matches[0]}
>
> Jacques
>
>

Old 03-30-2007   #5 (permalink)
Flowering Weeds
Guest


 

Re: Log Parser - Plain, COM, .NET


"Jacques Barathon [MS]"

>
> And finally a plain native PowerShell version :-) :
>
> PS> type $pshome\en-us\default.help.txt


Mmmm

PS> LogParser "type $pshome\en-us\default.help.txt"
Error: Syntax Error: <select-clause>: no SELECT keyword

It seems "a plain native PowerShell
version" ran in Log Parser 2.2 does
not work!



Old 03-30-2007   #6 (permalink)
Flowering Weeds
Guest


 

Re: Log Parser - Plain, COM, .NET


"Rob Campbell"

> If I was just processing text,
> I wouldn't user LogParser.
>


If your files are large and at different
locations perhaps one would!

> What I'm after is a function that will
> read a saved Windows Event Log file,


PS> LogParser -h -i:EVT

Input format: EVT (Windows Event Log)
Parses the Windows Event Log

And

PS> LogParser -h -i:ETW

Input format: ETW (Event Tracing for Windows)
Parses ETW binary logs or live trace sessions

FROM syntax:

<session_name> | <filename_list>
Name of an ETW tracing session or
comma-separated list of .etl filenames

> and return a custom PS object


Perhaps first, start with "text"
"and return a custom PS object"!



Old 03-30-2007   #7 (permalink)
Rob Campbell
Guest


 

Re: Log Parser - Plain, COM, .NET

I'm afraid it's too late to start with text.

I've got it reading in unfiltered event log file entries using COM, and am
working on looking at the returns from various getvalue operations and how
they would map the the object properties.

"Flowering Weeds" wrote:

>
> "Rob Campbell"
>
> > If I was just processing text,
> > I wouldn't user LogParser.
> >

>
> If your files are large and at different
> locations perhaps one would!
>
> > What I'm after is a function that will
> > read a saved Windows Event Log file,

>
> PS> LogParser -h -i:EVT
>
> Input format: EVT (Windows Event Log)
> Parses the Windows Event Log
>
> And
>
> PS> LogParser -h -i:ETW
>
> Input format: ETW (Event Tracing for Windows)
> Parses ETW binary logs or live trace sessions
>
> FROM syntax:
>
> <session_name> | <filename_list>
> Name of an ETW tracing session or
> comma-separated list of .etl filenames
>
> > and return a custom PS object

>
> Perhaps first, start with "text"
> "and return a custom PS object"!
>
>
>
>

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Yep More Log Parser Charting Flowering Weeds PowerShell 0 1 Week Ago 02:47 PM
Log Parser Get web text Flowering Weeds PowerShell 0 06-12-2008 04:37 PM
More Log Parser and PowerShell Flowering Weeds PowerShell 2 10-27-2007 02:53 PM
cannot find MS XML Parser 4.0 Maverique Vista General 7 06-27-2007 09:33 PM
Looking for HTML parser Shafik PowerShell 1 05-08-2007 09:33 PM








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