DFS Replication Chokes on Temporary File Attribute

Today I have come across one of those weird issues that take a lot of time to analyze and resolve. One single file was not replicated using DFS-R. But if the content was copied to a new file, replication worked as expected. Let me show you what caused this behaviour.

What Happend with DFS-R?

I was involved in the issue because I had designed and built the file server based on DFS-N and DFS-R. When a certain file was placed on any target server of any replicated folder, it was not replicated to any other target server.

The First Hint

To get a better understanding of this issue, I copied the contents of the file and created a new file. For some reason this new file was successfully replicated to all other target servers. This could only mean that the cause for this issue lies in the file metadata. When comparing the properties of the file at hand with another file that was replicated successfully, I came across file attribute called T:

Comparison of the details tab in the file properties. The good file only has the attribute "A" but the bad file has the attributes "AT" set. The bad file was skipped by DFS replication (DFS-R)

When taking a closer look using PowerShell, the file attribute called T in the GUI resolved to “Temporary”:

Get-Item for the bad file shows that the attributes "Archive" and "Temporary" are set. Maybe DFS replication did not work because of this

Although I could not be sure that this was the root cause, I continued investigating how to clear and set the attributes. Unfortunately, the good old attrib.exe was not able to help. So I turned back to PowerShell.

The Solution

It turns out that the temporary file attribute is among those file attributes that can only be modified by using binary operations. I came across this very helpful post describing how to handle file attributes and an example how to clear the attribute. In the end, I was able to proove that the temporary file attribute was the root cause for the DFS replication to fail for any file with this attribute set.

Unfortunately, I was unable to determine how this file attribute was set in the first place.

The Code

The following cmdlets implement setting and clearing the temporary file attribute:You can use any of the following commands to clear the temporary file attribute. Of course, settings works exactly the same way.

HTH!

Feedback is always welcome! If you'd like to get in touch with me concerning the contents of this article, please use Twitter.