DFSR Does Not Replicate Temporary Files

A time ago I had to move data from a old server to a new server.
 
I chose to do this with help of DFS Replication, because it replicates automatically without to much hassle and it's easy to configure.

Also it would maintain the security settings of the files and folders.
After a while I ran a DFS Diagnostic report to check how many files are synced in the replication group and if the numbers where the same between the source server and its destination.
 
I noticed that i was missing a few hundred files... not the news you wanted to read.
So I checked which files that were by searching them on the old server; the DFSR report showed me a couple of files that were not synced.
 
By checking the files; I at first didn't noticed something odd. After searching I came across this technet blog.
 
The problem was that some files had the attribute TEMPORARY set, by nature DFSR does not replicate them because of this.
 
To solve this you should search every file within the 'problem' folder that has the TEMP attribute set and remove it.
Good news; Power Shell can do that for you :)
 
Open Power Shell ISE in Administrator mode and paste this:
 
Get-childitem "D:\Your Problem Folder" -recurse | ForEach-Object -process {if (($_.attributes -band 0x100) -eq 0x100) {$_.attributes = ($_.attributes -band 0xFEFF)}}
 
After this, force a resync for you DFS replicated folders and check if the files of source and destination are the same.
 
Cheers,
David