0

I have a Powershell script which monitors several mapped drives for new files. Most of the mapped drives are other Windows systems. One is an NFS share on a Solaris system. Code snippet below:

clear
#$dir = "X:\sample_folder"
#$dir = "Y:\sample_folder"
#X is a Windows share. Y is an NFS share.

#ls works on drives X and Y
ls $dir

$watcher = New-Object System.IO.FileSystemWatcher $dir

Register-ObjectEvent $watcher Created -SourceIdentifier FileCreated -Action {
    $name = $Event.SourceEventArgs.Name
    Write-Host "New file $name"
    }

This code works fine if I uncomment the line for drive X, the Windows share. If I instead uncomment drive Y, the NFS share, it fails. It doens't produce any errors at runtime; it simply doesn't produce output when new files are made in the target folder.

I imagine FileSystemWatcher can only monitor NTFS volumes? If so, what should I use (in Powershell) to monitor an NFS share?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.