Powershell – DFS – List Backlog On All Replication Groups

This powershell script lists the DFS backlog on all folders in all replication groups in the domain

This will only work for DFS Replication groups on 2012 OS and higher, so the code takes into account that.

This expands on my previous post on how to check the DFS Backlog for a specific folder

 

$CurrentDatetime = get-Date -UFormat %y%m%d%H%M
$ListOfDFSConnections = Get-DfsReplicatedFolder 

        $CurrentDatetime = Get-Date -UFormat %y%m%d%H%M
        foreach ($item in $ListOfDFSConnections)
            {
            $Group = Get-DfsrConnection -GroupName $item.GroupName
            foreach ($Connection in $Group)
                {
                #Need to check Os version of source and destination as cmdlet Get-DFSRBacklog does not work lower than 2012 
                $SourceComputerNameOS = (get-adcomputer -identity $Connection.SourceComputerName -properties *).operatingsystem
                $DestinationComputerNameOS = (get-adcomputer -identity $Connection.DestinationComputerName -properties *).operatingsystem
                               
                if ( ( $SourceComputerNameOS -notlike "*2012*") -or ($DestinationComputerNameOS -notlike "*2012*")) #if OS is not 2012
                    {
                   # Write-host $CurrentDatetime "Group:"$item.GroupName "Source:"$SourceComputerNameOS "Destination:"$DestinationComputerNameOS -foregroundcolor Yellow
                    }
                else #If OS is 2012
                    {
                    $QueueLength = (Get-DfsrBacklog -Groupname $item.GroupName -FolderName $item.FolderName  -SourceComputerName $Connection.SourceComputerName   -DestinationComputerName $Connection.DestinationComputerName  -verbose 4>&1).Message.Split(':')[2]   
                    write-host $CurrentDatetime "Group:"$item.GroupName  "Folder:"$item.FolderName  "Source:"$Connection.SourceComputerName   "Destination:"$Connection.DestinationComputerName "Queue Length:"$QueueLength
                    #write-host   $CurrentDatetime "waiting till "$item.FolderName" $QueueLength count equals 0" 
                    }
                }
            }

 

 

 

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.