View Single Post
Old 09-18-2007   #1 (permalink)
Jay


 
 

Script file has 'OS Handle' error when run from script

For my batch automation product, ActiveBatch, I've written a ps1 which is
called from a cmd file, and which runs fine when run from command prompt.
The script runs fine from a command prompt, but when I run it from within
ActiveBatch, it starts off ok but then fails with this message:

"Write-Host : The OS handle's position is not what FileStream expected. Do
not use a handle simultaneously in one FileStream and in Win32 code or
another FileStream. This may cause data loss."

The code it doesn't like is a write-host that documents the script's
progress. Interactively, messages appear on the console, but as it's being
run by ActiveBatch the messages are being written to a log file. The first 3
messages appear in the log file ok:

C:\XXExtract\XXExtract_Scripts>powershell .\XXExtract.ps1 "userid"
"password"
16:20:00: Initialising
16:20:00: Getting subs list
16:20:00: Processing XXXX sp
(return status = 0)

The point at which it's failing is when the '(return status = 0)' message is
generated, which I've checked by redirecting it: > NULL, whereupon the error
doesn't appear there, but then does appear for subsequent messages.
Actually, I'd like to keep all the output in the log file.

The message isn't documented anywhere I can find. Can anybody explain why it
might be getting upset and what I can do to get all my messages logged and a
happy and fulfilled script?

Jay



My System SpecsSystem Spec