-
Notifications
You must be signed in to change notification settings - Fork 1
/
saveCrashReportsToDropbox.ps1
23 lines (22 loc) · 1.12 KB
/
saveCrashReportsToDropbox.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
### SET FOLDER TO WATCH + FILES TO WATCH + SUBFOLDERS YES/NO
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "C:\Users\Matthieu\AppData\Roaming\Ableton\Live Reports"
$watcher.Filter = "*.zip"
$watcher.IncludeSubdirectories = $false
$watcher.EnableRaisingEvents = $true
### DEFINE ACTIONS AFTER AN EVENT IS DETECTED
$action = { $path = $Event.SourceEventArgs.FullPath
$changeType = $Event.SourceEventArgs.ChangeType
$logline = "$(Get-Date), $changeType, $path"
Write-Host "$logline" -fore green
Add-content "C:\Users\Matthieu\AppData\Roaming\Ableton\Live Reports\log.txt" -value $logline
Copy-Item "$path" -Destination "D:\Saved\2019\Ableton\Crash report"
}
### DECIDE WHICH EVENTS SHOULD BE WATCHED
$registered_action = Register-ObjectEvent $watcher "Created" -Action $action
# Register-ObjectEvent $watcher "Changed" -Action $action
# Register-ObjectEvent $watcher "Deleted" -Action $action
# Register-ObjectEvent $watcher "Renamed" -Action $action
while ($true) {
sleep 5
}