Out-File not reporting error on failure to write to UNC network path when stream is being repeatedly opened and closed. #21545
Labels
Needs-Triage
The issue is new and needs to be triaged by a work group.
Prerequisites
Steps to reproduce
I am trying to extract a representative sample of a 200MB csv file by writing the header and every 500th row to a new file for testers to use. I relied on out-file -append to add each row matching the modulus condition to the destination file on network share, but what I found is that I had slightly fewer rows in the sample file than expected. Repeated runs produced slightly different numbers of rows in the destination file (expected 2014, actual ranged between 1992-2011). I did not get an terminating error.
The behaviour does NOT occur if I use a location on my local hard drive for the destination file.
I tried a suggested alternative of switching to the native API call:
That still doesn't produce a terminating error in Powershell 7.4.2, but does in Windows Powershell 5.1
Out-File to a UNC path doesn't produce a terminating error in Powershell 7.4.2 or 5.1.
Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: