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/

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/

Similar Messages

Maybe you are looking for