Skip to content

Instantly share code, notes, and snippets.

@itpropro
Created March 23, 2016 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itpropro/4fe050c1a2c211814390 to your computer and use it in GitHub Desktop.
Save itpropro/4fe050c1a2c211814390 to your computer and use it in GitHub Desktop.
# When a document is created in D:\Test with the extension .rtf This script will print its name
Register-CimIndicationEvent -Query "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE
TargetInstance ISA 'CIM_DataFile' AND (TargetInstance.Drive='D:' AND TargetInstance.Path='\\Test\\' AND TargetInstance.Extension='rtf')" -Action {
Write-Host $($Event.SourceEventArgs.NewEvent.TargetInstance.Name)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment