5

I have a script that's using PowerShell's Register-ObjectEvent to watch a folder for changes. Since the Register-ObjectEvent only works while the PowerShell session is active, I need to keep a PowerShell window open - which I'd rather not do.

I'd like to know if there is there a way to run Register-ObjectEvent in the background somehow?

1

1 Answer 1

3

Register-ObjectEvent will only run during the PowerShell session. WMI offers the ability to subscribe to WMI events (like new files or changes to files) and to run commands based on that, so you might want to investigate permanent WMI event registrations

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.