Created
July 2, 2014 21:41
-
-
Save pcgeek86/b5f29ab8a11b414b230f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$MyFilter = New-WmiEventFilter –Name WatchFolderRoboCopy –Query 'SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE TargetInstance ISA "CIM_DirectoryContainsFile" AND TargetInstance.GroupComponent = "Win32_Directory.Name=\"c:\\\\FileHistory\""' –EventNamespace "root\cimv2" | |
$MyConsumer = New-WmiEventConsumer –ConsumerType CommandLine –Name WatchFolderRoboCopy –CommandLineTemplate "c:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -<<<ParameterName1>>> %TargetInstance.<<<WmiPropertyName>>>%" | |
New-WmiFilterToConsumerBinding –Filter $MyFilter –Consumer $MyConsumer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment