how to fix this is who in the picture ?

I use this script in server 2008 R2 for Storing Windows Event Viewer Output in a SQL Server table with PowerShell :

foreach ($server in Get-Content c:tempservers.txt) { $variable = ( Get-EventLog -ComputerName $server -LogName Security -After 22-08-2011 | select @{Expression={$($server) };Label = ComputerName} ,index,TimeGenerated,EntryType,Source,InstanceID,Message ) $valuedatatable = Out-DataTable -InputObject $variable Write-DataTable -ServerInstance YourServer -Database YourDatabase -TableName EventError -data $valuedatatable 

the link : https://www.simple-talk.com/blogs/2011/08/31/storing-windows-event-viewer-output-in-a-sql-server-table-with-powershell/


February 15th, 2014 1:43am

It is wrong interpretation of $valuedatatable in 275 character. Perhaps something like | is missing in front of assigmnet of this variable. Second possible reason is something like recurrency

$valuedatatable = ....   -data $valuedatatable

I would recommend to rewrite this in more than one line.

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2014 3:45am

$valuedatatable = ....   -data $valuedatatable

I would recommend to rewrite this in more than one line.

how to rewrite this script or how is the form final solution of the script ?

please help !

February 15th, 2014 4:51am

Well the most obvious thing that stands out is that you are missing a closing "}" for your foreach statement.  I would also reformat it to look like this:

foreach ($server in Get-Content c:tempservers.txt) 
{ 
    $variable = ( Get-EventLog -ComputerName $server -LogName Security -After 22-08-2011 | select @{Expression={$($server) };Label = ComputerName} ,index,TimeGenerated,EntryType,Source,InstanceID,Message )
    $valuedatatable = Out-DataTable -InputObject $variable 
    Write-DataTable -ServerInstance YourServer -Database YourDatabase -TableName EventError -data $valuedatatable
}

Free Windows Admin Tool Kit Click here and download it now
February 15th, 2014 1:19pm

Well the most obvious thing that stands out is that you are missing a closing "}" for your foreach statement.  I would also reformat it to look like this:

foreach ($server in Get-Content c:tempservers.txt) 
{ 
    $variable = ( Get-EventLog -ComputerName $server -LogName Security -After 22-08-2011 | select @{Expression={$($server) };Label = ComputerName} ,index,TimeGenerated,EntryType,Source,InstanceID,Message )
    $valuedatatable = Out-DataTable -InputObject $variable 
    Write-DataTable -ServerInstance YourServer -Database YourDatabase -TableName EventError -data $valuedatatable
}

I try with your script but dont working and dont Storing Windows Event Viewer Output in a SQL Server table with PowerShell

please check this link Is this the way a successful ?

https://www.simple-talk.com/blogs/2011/08/31/storing-windows-event-viewer-output-in-a-sql-server-table-with-powershell/

February 18th, 2014 9:23am

Well the most obvious thing that stands out is that you are missing a closing "}" for your foreach statement.  I would also reformat it to look like this:

foreach ($server in Get-Content c:tempservers.txt) 
{ 
    $variable = ( Get-EventLog -ComputerName $server -LogName Security -After 22-08-2011 | select @{Expression={$($server) };Label = ComputerName} ,index,TimeGenerated,EntryType,Source,InstanceID,Message )
    $valuedatatable = Out-DataTable -InputObject $variable 
    Write-DataTable -ServerInstance YourServer -Database YourDatabase -TableName EventError -data $valuedatatable
}

I try with your script but dont working and dont Storing Windows Event Viewer Output in a SQL Server table with PowerShell

please check this link Is this the way a successful ?

https://www.simple-talk.com/blogs/2011/08/31/storing-windows-event-viewer-output-in-a-sql-server-table-with-powershell/

Free Windows Admin Tool Kit Click here and download it now
February 21st, 2014 2:40am

Do you have the Write-DataTable and Out-DataTable functions defined in your code or have you imported a module that contains them? Also, can you attach or show the actual error your getting now?
February 21st, 2014 2:55am

Do you have the Write-DataTable and Out-DataTable functions defined in your code or have you imported a module that contains them? Also, can you attach or show the actual error your getting now?
Free Windows Admin Tool Kit Click here and download it now
February 21st, 2014 10:52am

Do you have the Write-DataTable and Out-DataTable functions defined in your code or have you imported a module that contains them? Also, can you attach or show the actual error your getting now?
February 21st, 2014 10:52am

thank you Anthony James Brown , can you explain more what you mean :

  1. have the Write-DataTable and Out-DataTable  , how can it .
  2. have imported a module .
  • please tutorial and explain more , I am a beginner to use (windows powershell) .
Free Windows Admin Tool Kit Click here and download it now
March 15th, 2014 2:07am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics