Well is there an error when it fails? Thanks, Brian Desmond [email protected]<mailto:[email protected]>
c - 312.731.3132 From: Joseph L. Casale [mailto:[email protected]] Sent: Wednesday, January 26, 2011 4:39 PM To: NT System Admin Issues Subject: PowerShell io notify sporadic behavior On my Win7 x86 wkst's, this code works every time, perfectly. On a vanilla 2008r2 server, it sometimes works, but mostly always fails to move the file? Anyone have an idea why that might be? $folder = 'D:\Test' $filter = '*.*' $destination = 'D:\Test2' $fsw = New-Object IO.FileSystemWatcher $folder, $filter -Property @{ IncludeSubdirectories = $true NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite' } $onCreated = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action { $path = $Event.SourceEventArgs.FullPath $name = $Event.SourceEventArgs.Name $changeType = $Event.SourceEventArgs.ChangeType $timeStamp = $Event.TimeGenerated Write-Host "The file '$name' was $changeType at $timeStamp" Move-Item $path -Destination $destination -Force -Verbose } Thanks! jlc ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected]<mailto:[email protected]> with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
