LoginSignup
6

More than 3 years have passed since last update.

PowerShellでファイル作成監視ワンライナー

Last updated at Posted at 2019-06-12

何度も使うと意外と覚えられます

監視登録

$ Register-ObjectEvent -InputObject (New-Object System.IO.FileSystemWatcher("$HOME/Desktop")) -SourceIdentifier "test" -EventName Created {(New-Object -ComObject wscript.shell).popup("ファイル:" + $EventArgs.FullPath.toString() + "が配置されました。")}

デスクトップに新しいファイルが配置、作成されるとダイアログが出ます。
image.png

監視解除

$ Unregister-Event -SourceIdentifier "test"

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6