Error when redirecting stdout and stderr of powershell script
Lee Holmes (one of the senior developers on the powershell team) covers this here in a blog post:
http://www.leeholmes.com/blog/WorkaroundTheOSHandlesPositionIsNotWhatFileStreamExpected.aspx
This is bug in PowerShell v1.0, and happens when:
- a PowerShell command generates both regular and error output
- you have used cmd.exe to redirect the output to a file
- you have used cmd.exe to merge the output and error streams
There is a workaround.
-Oisin
I once had several hard-linked junctions at directory that needed to have "GetItemChild" applied, and received the same error as this question.
Removing the junctions solved the problem.