Powershell and DfsrConfigurationFromAD – how to check all servers are updated

dfs-rpowershellwindows-server-2012-r2

I have two Win2012R2 servers (SERVER1 and SERVER2) that uses DFS Replication for keeping a couple of folders synchronized.

Using the following Powershell-script that i run on SERVER1 I disconnect it from the group:

Set-DfsrConnection -GroupName "Group1" -SourceComputerName "SERVER1" -DestinationComputerName "SERVER2" -DisableConnection $True;

And to update both the servers with the configuration I run the command:

Update-DfsrConfigurationFromAD -ComputerName "SERVER1","SERVER2"

Now the question is, how can check on SERVER1 that SERVER2 has gotten the updated information from the AD so that I can be sure that the connection has been disabled? Usually it takes around 10-30 seconds after the Update-DfsrConfigurationFromAD command has been run before the DFS Management on SERVER2 gets updated but I need some kind of a "check and sleep loop" in my code.

I've tried checking event logs and using Invoke-Command {Get-DfsrConnection} from PM-SERVER01 but nothing seems to work.

Best Answer

I'd think you could use Get-DfsrMembership against a particular server to determine what groups it has membership in:

Get-DfsrMembership -GroupName * -ComputerName "SERVER2"
Related Topic