Como existem algumas visões sobre isso, postarei o script corrigido, conforme apontado por Techie007. Foi apenas um pequeno erro de digitação e este postagens para Slack se você gostaria de usar scripts Powershell para assistir a pastas no Windows:
### SET FOLDER TO WATCH + FILES TO WATCH + SUBFOLDERS YES/NO
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "C:\Location\"
$watcher.Filter = "*.*"
$watcher.IncludeSubdirectories = $false
$watcher.EnableRaisingEvents = $true
### DEFINE ACTIONS AFTER A EVENT IS DETECTED
$action = { $path = $Event.SourceEventArgs.FullPath
$changeType = $Event.SourceEventArgs.ChangeType
$token = ""
$channel = "#general"
$text = "$changeType, $path"
$username = "Bot User"
$postSlackMessage = @{token=$token; channel=$channel; text=$text; username=$username}
Invoke-RestMethod -Uri https://slack.com/api/chat.postMessage -Body $postSlackMessage
}
### DECIDE WHICH EVENTS SHOULD BE WATCHED + SET CHECK FREQUENCY
$created = Register-ObjectEvent $watcher "Created" -Action $action
$changed = Register-ObjectEvent $watcher "Changed" -Action $action
$deleted = Register-ObjectEvent $watcher "Deleted" -Action $action
$renamed = Register-ObjectEvent $watcher "Renamed" -Action $action
while ($true) {sleep 5}