# Kyylataan haluttua hakemistoa ja ilmoitetaan muutoksista # jej, 22.8.2011 # 1) Käynnistä PowerShell (1. kerran adminina jotta seuraava menee läpi) # 2) Set-ExecutionPolicy -executionPolicy unrestricted # 3) .\tutki.ps1 # $searchPath = "C:\Users\vesal\Dropbox\riippu\sm19" $watcher = New-Object System.IO.FileSystemWatcher $watcher.Path = $searchPath $watcher.IncludeSubdirectories = $true $watcher.EnableRaisingEvents = $true write-host "Started monitorig directory " $searchPath $changed = Register-ObjectEvent $watcher "Changed" -Action { write-host "Changed: $($eventArgs.FullPath)" $runThis = "xcopy *.* w:\riippu\tuloksia\19\sm19 /y /d /s" invoke-expression -command $runThis } $created = Register-ObjectEvent $watcher "Created" -Action { write-host "Created: $($eventArgs.FullPath)" } $deleted = Register-ObjectEvent $watcher "Deleted" -Action { write-host "Deleted: $($eventArgs.FullPath)" } $renamed = Register-ObjectEvent $watcher "Renamed" -Action { write-host "Renamed: $($eventArgs.FullPath)" }