简体   繁体   English

每当从Windows 7中的共享文件夹中删除文件时发送电子邮件

[英]Send an email whenever file is deleted from shared folder in windows 7

I am running a software on several computers at my workplace and the software can run different audio and video files stored on a shared folder in a central computer. 我在工作场所的多台计算机上运行一个软件,该软件可以运行存储在中央计算机共享文件夹中的不同音频和视频文件。 The software runs on windows 7 and every person in my company can add or remove files from the shared folder, but this privilege puts the data at risk. 该软件在Windows 7上运行,我公司的每个人都可以从共享文件夹中添加或删除文件,但是此特权会使数据处于危险之中。 I was thinking of creating an email alert to my self whenever a file is deleted. 每当删除文件时,我就想创建一个针对自己的电子邮件警报。 I have written a windows powershell script for sending me emails from smtp server but how can I hook it up to the event of file or folder deletion in a specific shared folder? 我已经编写了一个Windows powershell脚本,用于从smtp服务器向我发送电子邮件,但是如何将其连接到特定共享文件夹中的文件或文件夹删除事件呢?

Honestly, if you want real time monitoring (I'm guessing you do since you're wanting an email alert sent to you when you detect file deletion), then the hardest part is going to be keeping the script running... 老实说,如果您想进行实时监控(我想您是因为要在检测到文件删除时向您发送电子邮件警报),那么最困难的部分将是保持脚本的运行...

Anyway, the first two things you're going to need to do are 1) Enable the Audit Policy "Audit Object Access" on the server hosting the share 2) Enable auditing for the user/group you're monitoring 无论如何,您需要做的前两件事是1)在托管共享的服务器上启用审核策略“审核对象访问” 2)对正在监视的用户/组启用审核

After that, you're going to want to use the Get-Eventlog cmdlet to search for event ID 4663 (you can also use event IDs 4656 and 4658 to correlate the event - they represent the opening and closing of a given file). 之后,您将要使用Get-Eventlog cmdlet搜索事件ID 4663(也可以使用事件ID 4656和4658关联事件-它们代表给定文件的打开和关闭)。

Anyway, after you've enabled auditing, use something like this get started: 无论如何,在启用审核之后,请使用类似以下内容的入门:

Get-EventLog security | Where-Object {$_.EventID -eq 4663}

Oh, and to keep it running, you'll probably want to use a scheduled job. 哦,为了保持它的运行状态,您可能要使用计划的作业。

Or you could use an IO.FileSystemWatcher object and register an event. 或者,您可以使用IO.FileSystemWatcher对象并注册一个事件。

Grts. GRTS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在文件夹/目录中找到最新文件,然后使用Windows cmd或Powershell中的Shell脚本通过电子邮件发送该文件 - Find the most recent file in a folder/dir and send that file in a email using shell script in windows cmd or powershell 如何从 Windows 批处理文件发送简单的电子邮件? - How to send a simple email from a Windows batch file? 以编程方式从共享邮箱发送 Outlook 电子邮件 - programmatically send outlook email from shared mailbox Windows在共享文件夹中创建不可删除文件 - Windows create undeletable file in shared folder 如何从 Windows 服务中 FileSystemWatcher 监视的共享文件夹中放置的文件中获取用户名 - How to get username from a file dropped in a shared folder monitored by FileSystemWatcher in a windows service Windows搜索共享文件夹 - Windows Search shared folder 将文件从服务器的共享文件夹复制到本地 - Copy file from shared folder of server to local 如何从Windows命令行创建共享文件夹? - How can I create a shared folder from the Windows command line? 从网络上Windows共享文件夹中使用php在Linux中读取目录 - directory reading in linux using php from windows shared folder on network 从Windows资源管理器中的共享文件夹执行bash脚本 - execute bash script from shared folder in windows explorer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM