Forum Discussion

Brandon's avatar
8 years ago

DFSR Replication Backlog

XKJNGZ

Uses Powershell to make WMI queries to get the current backlog file count for each outbound DFSR partner on each DFSR share.  These queries can be expensive if the backlog is large, so the polling interval is set to 10 minutes.  If there is no backlog, the script finishes quickly.  No default alerting is set, but I would recommend adding a threshold to be notified of potential replication issues.

 

NOTE* - The collector must be able to reach both DFSR partners and will use the same credentials to make the queries for both.

  • Hi, I'd also like to get this datasource going if possible.

    I too am getting "No instance is discovered for the selected device during this test", when doing an Active Discovery test. When I run the Active Discovery PS script manually on the collector server, it returns the expected data (3 DFS folder instances). When running it manually I'm pasting in the hostname, username and password to the script before running it.

     

  • At scale, using remote powershell with implicit sessions (-computername) in an environment using remote profiles can cause issues on the target servers... safer method is to use explicit sessions in an invoke-command -session with a noprofile flag (get-wmiobject doesn't allow a -session parameter):

    function Get-LMCreds_WMI {
        param (
            $wmi_user = '##WMI.USER##',
            $wmi_pass = '##WMI.PASS##'
        )
    
        if ([string]::IsNullOrWhiteSpace($wmi_user) -or ( $wmi_user -like '*WMI.USER*')) {
    
            write-output $null
    
        } else {
    
            $remote_pass = ConvertTo-SecureString `
                -String $wmi_pass                 `
                -AsPlainText                      `
                -Force
    
            $remote_credential = New-Object                         `
                -typename System.Management.Automation.PSCredential `
                -argumentlist $wmi_user, $remote_pass
    
            write-output $remote_credential
    
        }
    }
    function Get-Session     {
        $creds  = Get-LMCreds_WMI
        $option = New-PSSessionOption -NoMachineProfile
            
        if ($creds) {
            $session = new-pssession         `
                -computername  $computerName `
                -credential    $creds        `
                -SessionOption $option
        } else {
            $session = new-pssession         `
                -computername  $computerName `
                -SessionOption $option
        }
    
        write-output $session
    }
    
    try {
        
        $serverName    = hostname
        $computerName  = "##system.sysname##.##system.domain##"
        $payload       = {
            quser ### Example query to be made ###
        }
        
        if ($serverName -match "##system.sysname##") {
            #This is a Collector
            $outputString = invoke-command `
                -scriptblock $payload
               
        } else {
            # Not the Collector
            $session      = Get-Session
            $outputString = invoke-command `
                -session     $session      `
                -scriptblock $payload
        }
    } catch {
        write-error $error[0]
        write-output -1
    }
    
    if ($session) { remove-pssession $session }

    It's far more clunky, but in our environments, LM was causing our client users the ability to log in using anything other than a temporary profile most of the time.  This fixed it.  (WMI in the DataSource itself still does it with implicit sessions, so we minimize the number of WMI DS we use and replace them with powershell script DS using this method)