Quantcast
Channel: SQL Server Replication forum
Viewing all articles
Browse latest Browse all 4054

Powershell help for sql server

$
0
0
Hi All,

I wanted to load windows application log into sql server table. I am using below command but it was throwing error.
Can anyone help me on how to fix this problem.

Followed below article to load the windows event log to a table. I created below table and ran below powershell command
https://www.red-gate.com/simple-talk/blogs/storing-windows-event-viewer-output-in-a-sql-server-table-with-powershell/

CREATE TABLE [dbo].[EventViewer]
(
        [Index] [int] NULL,
        [Time] [datetime] NULL,
        [EntryType] [varchar](MAX) NULL,
        [Source] [varchar](MAX) NULL,
        [InstanceID] [varchar](MAX) NULL,
        [Message] [varchar](MAX) NULL
  )
GO


Get-EventLog   -ComputerName  <machine name>  -LogName  Application -After  "30-03-2020" |  select  index,TimeGenerated,EntryType,Source,InstanceID,Message | Out-DataTable | Write-DataTable -ServerInstance<machine name> -Database master -TableName EventViewer


Error message

Out-DataTable : The term 'Out-DataTable' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:159
+ ... Generated,EntryType,Source,InstanceID,Message | Out-DataTable | Write ...
+                                                     ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Out-DataTable:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


Powershell version
====================
PS C:\> Get-Host | Select-Object Version                                                                               
Version
-------
5.1.18362.628

Regards,
Sam

Viewing all articles
Browse latest Browse all 4054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>