Not sure what’s going wrong here. It seems to be running, but I keep getting Error Connecting to : No Events were found that match the specified selection criteria.<\/p>\n
$Computername = get-content \"C:\\Lindsay\\Computers.txt\"\n$StartTime = (get-date)\n$EndTime = (get-date).AddDays(-30)\n\n<# Event Log Levels\n 1 = Critical\n 2 = Error\n 3 = Warning\n 4 = Information\n 5 = Verbose \n #> \n$Levels = @('Placeholder-0','Critical','Error', 'Warning', 'Information', 'Verbose')\n\n$EventFilter = @{Logname='System','Application'\n Level=1,2,3,4\n StartTime=$StartTime\n EndTime=$EndTime\n } \n\nforeach($Computer in $Computername) {\n try {\n\n $Events = Get-WinEvent -ComputerName $Computer -Verbose:$false -ErrorAction Stop -FilterHashtable $EventFilter \n\n $Output = $Events | Select-Object @{n='Computer';e={$Computer}}, TimeCreated,LogName, @{n='Level';e={$Levels[$($_.Level)]}}, Message \n\n #Output to Screen\n $Output | ft\n\n #Export to File \n #Output | Out-File C:\\Lindsay\\WinEvents-$Computer.txt\n\n } catch {\n\n Write-warning \"Error connecting to server: $Computer - $($Error[0])\"\n }\n} \n<\/code><\/pre>","upvoteCount":4,"answerCount":11,"datePublished":"2019-09-26T13:48:57.000Z","author":{"@type":"Person","name":"talonzahntalonzahn","url":"https://community.spiceworks.com/u/talonzahntalonzahn"},"acceptedAnswer":{"@type":"Answer","text":"
Advertisement
It looks like your start and end times are reversed.<\/p>\n
$StartTime = (get-date)\n$EndTime = (get-date).AddDays(-30)\n<\/code><\/pre>\n
Advertisement
Usually the start time is the earlier date, and the end time is the later date.<\/p>","upvoteCount":0,"datePublished":"2019-09-26T14:48:33.000Z","url":"https://community.spiceworks.com/t/export-multiple-remote-server-event-logs/731935/7","author":{"@type":"Person","name":"Evan7191","url":"https://community.spiceworks.com/u/Evan7191"}},"suggestedAnswer":[{"@type":"Answer","text":"
Not sure what’s going wrong here. It seems to be running, but I keep getting Error Connecting to : No Events were found that match the specified selection criteria.<\/p>\n
$Computername = get-content \"C:\\Lindsay\\Computers.txt\"\n$StartTime = (get-date)\n$EndTime = (get-date).AddDays(-30)\n\n<# Event Log Levels\n 1 = Critical\n 2 = Error\n 3 = Warning\n 4 = Information\n 5 = Verbose \n #> \n$Levels = @('Placeholder-0','Critical','Error', 'Warning', 'Information', 'Verbose')\n\n$EventFilter = @{Logname='System','Application'\n Level=1,2,3,4\n StartTime=$StartTime\n EndTime=$EndTime\n } \n\nforeach($Computer in $Computername) {\n try {\n\n $Events = Get-WinEvent -ComputerName $Computer -Verbose:$false -ErrorAction Stop -FilterHashtable $EventFilter \n\n $Output = $Events | Select-Object @{n='Computer';e={$Computer}}, TimeCreated,LogName, @{n='Level';e={$Levels[$($_.Level)]}}, Message \n\n #Output to Screen\n $Output | ft\n\n #Export to File \n #Output | Out-File C:\\Lindsay\\WinEvents-$Computer.txt\n\n } catch {\n\n Write-warning \"Error connecting to server: $Computer - $($Error[0])\"\n }\n} \n<\/code><\/pre>","upvoteCount":4,"datePublished":"2019-09-26T13:48:57.000Z","url":"https://community.spiceworks.com/t/export-multiple-remote-server-event-logs/731935/1","author":{"@type":"Person","name":"talonzahntalonzahn","url":"https://community.spiceworks.com/u/talonzahntalonzahn"}},{"@type":"Answer","text":"If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n