Public/ps1/Files/Stop-ApprxrFileWatchers.ps1
|
<#
.SYNOPSIS Stops all running Apprxr file watcher jobs for all configured locations. .DESCRIPTION Finds and stops all background jobs associated with Apprxr file watcher locations, and logs each action. Used for cleanup and management of all watcher jobs. .EXAMPLE Stop-ApprxrFileWatchers Stops all watcher jobs for all configured locations. .NOTES This function is part of the Apprxr file watcher management system. #> function Stop-ApprxrFileWatchers { $locations = Get-ApprxrFileWatcherLocations if (-not $locations) { Log "No file watcher locations configured." return } foreach ($name in $locations.Keys) { $jobs = Get-Job | Where-Object { $_.Name -like "Apprxr$($name)*" } foreach ($job in $jobs) { try { Stop-Job $job -ErrorAction SilentlyContinue Remove-Job $job -ErrorAction SilentlyContinue Log "Stopped watcher job: $($job.Name) for location: $name" } catch { Log "Failed to stop watcher job: $($job.Name) for location: $name. Error: $_" } } } Log "All Apprxr file watcher jobs stopped." } |