This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$old = (Get-Date).AddHours(-1) | |
$before_lines = 50 | |
$after_lines = 50 | |
Write-Host "Pulling Warn/Error Windows Events started >= $old" | |
Get-WinEvent -ListLog * -EA silentlycontinue | | |
Where-Object { $_.recordcount -AND $_.lastwritetime -gt $old } | | |
ForEach-Object { get-winevent -FilterHashtable @{LogName=$_.logname; StartTime=$old } -EA silentlycontinue } | | |
Sort-Object TimeCreated | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://blogs.msdn.microsoft.com/calvin_hsia/2018/09/29/using-async-with-manualreseteventslim/ | |
// https://blogs.msdn.microsoft.com/pfxteam/2012/02/11/building-async-coordination-primitives-part-1-asyncmanualresetevent/ | |
internal class AsyncManualResetEvent | |
{ | |
private volatile TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(); | |
public Task WaitAsync() => this.tcs.Task; | |
public void Set() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Progress(long current, long total) | |
{ | |
if (InvokeRequired) | |
{ | |
BeginInvoke(new Action<long, long>(Progress), current, total); | |
} | |
else | |
{ | |
if (total <= 0 || current <= 0) | |
{ |