Solved

PowerShell Register-ObjectEvent FileSystemWatcher

Posted on 2013-01-09
1
860 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Set OWA language and time zone in Exchange for individuals, all users or per database.
A procedure for exporting installed hotfix details of remote computers using powershell
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 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