Solved

PowerShell Register-ObjectEvent FileSystemWatcher

Posted on 2013-01-09
1
840 Views
Last Modified: 2013-01-11
Hello,
I'm trying to utilize the .NET FileSystemWatcher to monitor a directory for changes. My script works but I've noticed the registered events are lost at log out. Is there a way to make these registered events persist through logout/reboot?
0
Comment
Question by:HumanScaleDev
1 Comment
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 38760677
It is an expected behavior. The event subscription will only available if the PowerShell is running. When you close the PS console, the event registration will be cleared.

You may turn on automatic logon and run the PowerShell script as a logon script with -noexit. I have never tried it but if it is an option for you then you can check it out.. :-)
Set objShell = CreateObject("Wscript.Shell")
objShell.Run("powershell.exe -noexit c:\scripts\test.ps1")

Open in new window

Ref :http://technet.microsoft.com/en-us/library/ee176949.aspx
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
Set OWA language and time zone in Exchange for individuals, all users or per database.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now