-
Notifications
You must be signed in to change notification settings - Fork 0
AER
neztach edited this page Aug 31, 2023
·
1 revision
| Code | Explanation |
$Watcher = [System.IO.FileSystemWatcher]::new('c:\tmp')
Register-ObjectEvent -InputObject $Watcher -EventName Created -Action {
Write-Host -Object 'New file created!!!'
} |
Register for filesystem events |
$Timer = [System.Timers.Timer]::new(5000)
Register-ObjectEvent -InputObject $Timer -EventName Elapsed -Action {
Write-Host -ForegroundColor Blue -Object 'Timer elapsed! Doing some work.'
}
$Timer.Start() |
Perform a task on a timer (ie. every 5000 milliseconds) |
neztach - PowerShell Public repo