Powershell Übergabe von Variable scheitert
Hallo und guten Tag
Ich möchte alle Ereignisprotokolle von Win2008 R2 Servern auslesen, in denen ein Fehler protokolliert wurde.
1. $yesterday = (get-date) - (new-timespan -day 3)
2. $VarLogName = get-winevent -listlog * -computername db2| where {$_.recordcount}| FT LogName -HideTableHeaders
3. get-winevent -computername db2 -logname $VarLogName -maxevents 10 | where {$_.timecreated -ge $yesterday} | where {$_.leveldisplayname -eq "Fehler"} |ft
In Zeile drei bekomme ich folgende Fehlermeldung:
Get-WinEvent : Auf dem Computer "db2" wurde kein Ereignisprotokoll gefunden, das "Microsoft.PowerShell.Commands.Internal.Format.FormatEndData" entspricht.
Bei C:\Users\KUENNE~1\AppData\Local\Temp\Untitled1.ps1:64 Zeichen:13
"+ get-winevent <<<< -computername db2 -logname $A -maxevents 10 | where {$_.timecreated -ge $yesterday} | where {$_.leveldisplayname -eq "Fehler"} |ft"
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...t.FormatEndData:String) [Get-WinEvent], Exception
+ FullyQualifiedErrorId : NoMatchingLogsFound,Microsoft.PowerShell.Commands.GetWinEventCommand
Wie kann ich das Problem umgehen?
Danke.
1. $yesterday = (get-date) - (new-timespan -day 3)
2. $VarLogName = get-winevent -listlog * -computername db2| where {$_.recordcount}| FT LogName -HideTableHeaders
3. get-winevent -computername db2 -logname $VarLogName -maxevents 10 | where {$_.timecreated -ge $yesterday} | where {$_.leveldisplayname -eq "Fehler"} |ft
In Zeile drei bekomme ich folgende Fehlermeldung:
Get-WinEvent : Auf dem Computer "db2" wurde kein Ereignisprotokoll gefunden, das "Microsoft.PowerShell.Commands.Internal.Format.FormatEndData" entspricht.
Bei C:\Users\KUENNE~1\AppData\Local\Temp\Untitled1.ps1:64 Zeichen:13
"+ get-winevent <<<< -computername db2 -logname $A -maxevents 10 | where {$_.timecreated -ge $yesterday} | where {$_.leveldisplayname -eq "Fehler"} |ft"
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...t.FormatEndData:String) [Get-WinEvent], Exception
+ FullyQualifiedErrorId : NoMatchingLogsFound,Microsoft.PowerShell.Commands.GetWinEventCommand
Wie kann ich das Problem umgehen?
Danke.
Please also mark the comments that contributed to the solution of the article
Content-Key: 170548
Url: https://administrator.de/contentid/170548
Printed on: April 24, 2024 at 22:04 o'clock