# Power shell script to automatically run when timstamp of a file changes

**URL:** <https://forums.powershell.org/t/power-shell-script-to-automatically-run-when-timstamp-of-a-file-changes/21957>\
**Category:** PowerShell Help\
**Created:** [March 25, 2023, 6:04am UTC](https://forums.powershell.org/t/power-shell-script-to-automatically-run-when-timstamp-of-a-file-changes/21957 "2023-03-25T06:04:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maheshtyagi](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Maheshtyagi](https://forums.powershell.org/u/Maheshtyagi)\
**Post date:** [March 25, 2023, 6:04am UTC](https://forums.powershell.org/t/power-shell-script-to-automatically-run-when-timstamp-of-a-file-changes/21957/1 "2023-03-25T06:04:23Z")

</div>

I have a power shell script.  
it zips a file and send it across.  
i want my script to automatically perform this step when time stamp of that file gets updated.  
can i do it with help of a trigger or something.  
Thanks.  
\*this is urgent and suggestions will be highly appreciated.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [March 25, 2023, 8:56am UTC](https://forums.powershell.org/t/power-shell-script-to-automatically-run-when-timstamp-of-a-file-changes/21957/2 "2023-03-25T08:56:53Z")

</div>

Maheshtyagi,  
Welcome to the forum. 👋🏼

At first I’d like to comment on that:

> [@Maheshtyagi](#):
>
> \*this is urgent …

On stackoverflow there is an answer that applies actually to all peer to peer forums where you expect others to voluntarily help you with your challenges. Please read it carefully.

> <https://meta.stackoverflow.com/questions/326569/under-what-circumstances-may-i-add-urgent-or-other-similar-phrases-to-my-quest/326590#326590>

> [@Maheshtyagi](#):
>
> i want my script to automatically perform this step when time stamp of that file gets updated.  
> can i do it with help of a trigger or something.

You could use either a recurring scheduled task running every few minutes and check the time stamp or you may use a `FileSystemWatcher`.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [February 10, 2024, 5:34pm UTC](https://forums.powershell.org/t/power-shell-script-to-automatically-run-when-timstamp-of-a-file-changes/21957/3 "2024-02-10T17:34:04Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
