Following this earlier post on troubleshooting DFSR replication conflicts for SYSVOL I got some questions on how to clear out the ConflictAndDeleted folder where DFSR keeps the conflicted files. Usually, there is no need to do this, but you might want to clear the folder after you fixed something in DFSR and want to observe the results. Or, perhaps you just like things to be neat. Anyway, if you look into this you will quickly arrive at this blogpost from ASKDS: Manually Clearing the ConflictAndDeleted Folder in DFSR. It shows to ways to do it: properly using WMI, or the sledgehammer approach by stopping the DFSR service and removing its administration. The WMI method in this blog posts uses a multi-step approach with the command line tool wmic which works fine but is simply not PowerShell. So, I decided to roll my own variation.
The short version is this oneliner:
Get-CimInstance -ComputerName dc23.earth.sol.local -Namespace root/MicrosoftDfs -ClassName DfsrReplicatedFolderInfo -filter "ReplicationGroupName = 'Domain System Volume'" | Invoke-CimMethod -name cleanupconflictdirectory
For this to work you need PowerShell 3.0 or higher. The destination computer (dc23.earth.sol.local) must be a DC where SYSVOL runs in DFSR mode, which is the modern default. The oneliner will simply clear the ConflictAndDeleted folder and reset its administration. We use Get-CimInstance to find the DFSR Replication Group hosting SYSVOL. We feed this object to Invoke-CimMethod and use it to execute the cleanupconflictdirectory method.
The long version is a script that enables you to clear multiple DCs in one shot, with some error handling included. If you are interested, take a look on the TechNet gallery: https://gallery.technet.microsoft.com/Clear-DFSR-ConflictAndDelet-66a1d81c.