Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 870551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:29:46+00:00 2026-05-15T10:29:46+00:00

I am using the below PowerShell function to parse event logs that have been

  • 0

I am using the below PowerShell function to parse event logs that have been saved locally from a remote machine. Unfortunately, I cannot for the life of me figure out how to dump out to another format instead of just to the console window.

When I insert an INTO statement into my SQL query I get the following error:

Exception calling “Execute” with “2” argument(s): “Cannot specify an INTO-entity when calling Execute() [The parameter is incorrect.]”

Any help is greatly appreciated.

    Function Parse-Event-Logs
{

$logtypes = "Application","System","Security"
foreach ($logtype in $logtypes)
{
$log_file = $LogsArchive + "\" + $folder + "\" + $logtype + ".evt"
$log_parser = new-object -comobject MSUtil.LogQuery
$log_type = new-object -comobject MSUtil.LogQuery.EventLogInputFormat
$log_type.resolvesids = $true
$log_type.fulltext = $true
$output_type = new-object -comobject MSUtil.LogQuery.NativeOutputFormat
$log_query = "SELECT * FROM $log_file  WHERE EventTypeName = 'Error event' OR EventTypeName = 'Warning event'"

$log_recs = $log_parser.execute($log_query,$log_type)
try{
do{
$lp_return = @{}
$log_entry = $log_recs.getrecord()

$lp_return.add("Index",$log_entry.getvalue("RecordNumber"))
$lp_return.add("EntryType",$log_entry.getvalue("EventTypeName"))
$lp_return.add("EventID",$log_entry.getvalue("EventID"))
$lp_return.add("Message",$log_entry.getvalue("Message"))
$lp_return.add("Category",$log_entry.getvalue("EventCategoryName"))
$lp_return.add("CategoryNumber",$log_entry.getvalue("EventCategory"))
$lp_return.add("ReplacementStrings",$log_entry.getvalue("Strings"))
$lp_return.add("Source",$log_entry.getvalue("SourceName"))
$lp_return.add("TimeGenerated",$log_entry.getvalue("TimeGenerated"))
$lp_return.add("TimeWritten",$log_entry.getvalue("TimeWritten"))
$lp_return.add("UserName",$log_entry.getvalue("SID"))
$lp_return | new-hashobject

$log_recs.movenext()
} while ($log_recs.atend() -eq $false)
}

Catch {Write-Host "Event log is empty"}
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:29:47+00:00Added an answer on May 15, 2026 at 10:29 am

    OK, converting the comment to an answer. 🙂

    Use the ExecuteBatch method instead of the Execute method. ExecuteBatch allows for passing in input and output types.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 530k
  • Answers 530k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I can't make out if you want to make your… May 16, 2026 at 11:42 pm
  • Editorial Team
    Editorial Team added an answer You use a stub return for a method call on… May 16, 2026 at 11:41 pm
  • Editorial Team
    Editorial Team added an answer Answering my own question again! Check there is no firewall… May 16, 2026 at 11:41 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm using the PowerShell script below to set anonymous user identity and authentication methods
I am using below code from one of my activity to start another Intent
I am using PowerShell 1.0 on Windows Server 2003 x64. When executing the following
Short version : I think I need help with properly using events in PowerShell
Background: Here the goal is to do some basic commands in powershell using select-string.
I'm trying to write a powershell script that updats each of the DiagnosticsConnectionString and
I am using the ilovesharepoint Lookup Field with Picker that is on codeplex on
I am using below javaScript code to create table in runtime. And i somewhat
I am using below code to apply different background color to odd and even
I am using XSLT1.0 for transforming my XML. I am having below Tabs.xml <?xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.