-
-
Save hospitableit/cd29f67737e23f35c8c7689d1d2dfc17 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Enter Domain Name | |
| $DomainName = "MyDomainName" | |
| #Enumerate Replication Groups into List ($Groups) | |
| $Groups = Get-dfsreplicationgroup | Sort-Object -Property GroupName | ForEach-Object {$_.GroupName} | |
| #Count the number of entries in the Replication Group list and minus one to use in the loop | |
| $GroupCountRaw = $Groups.Count | |
| $GroupCount = $GroupCountRaw - 1 | |
| #Output for PRTG | |
| Write-Host "<prtg>" | |
| #For each entry in $Groups | |
| For ($i=0; $i -le $GroupCount; $i++){ | |
| #Get the Folder for each Replication Group, our implementation only has one Folder per Replication Group | |
| $Folder = Get-dfsreplicatedfolder -DomainName $DomainName -GroupName $Groups[$i] | Sort-Object -Property FolderName | ForEach-Object {$_.FolderName} | |
| #Get the list of Computers in each Replication Group | |
| $ComputerNameList = Get-dfsrmember -DomainName $DomainName -GroupName $Groups[$i] | Sort-Object -Property ComputerName | ForEach-Object {$_.ComputerName} | |
| #Count the number of entries in the Computer Name list and minus one to use in the loop | |
| $ComputerNameListCountRaw = $ComputerNameList.Count | |
| $ComputerNameListCount = $ComputerNameListCountRaw - 1 | |
| #For each entry in $ComputerNameList | |
| For ($j=0; $j -le $ComputerNameListCount; $j++){ | |
| #Create a Destination Computer List by extracting the Current Source Computer from the Computer Name List | |
| $DestinationComputerNameList = $ComputerNameList -ne $ComputerNameList[$j] | |
| #Count the number of entries in the Destination Computer Name list and minus one to use in the loop | |
| $DestinationComputerNameListCountRaw = $DestinationComputerNameList.Count | |
| $DestinationComputerNameListCount = $DestinationComputerNameListCountRaw - 1 | |
| #For each entry in $DestinationComputerNameList | |
| For ($k=0; $k -le $DestinationComputerNameListCount; $k++){ | |
| #Get the backlog count | |
| $BacklogCount = (Get-DfsrBacklog -GroupName $Groups[$i] -FolderName $Folder -SourceComputerName $ComputerNameList[$j] -DestinationComputerName $DestinationComputerNameList[$k] -Verbose 4>&1).Message.Split(':')[2] | |
| #Assign a value of 0 if nothing is returned | |
| if (!$BacklogCount){$BacklogCount = 0} | |
| #Output to PRTG | |
| Write-Host "<result>" | |
| Write-Host ("<channel>Folder " + $Folder + " from " + $ComputerNameList[$j] + " to " + $DestinationComputerNameList[$k] + "</channel>") | |
| Write-Host ("<value>" + ($BacklogCount -replace " ", "") + "</value>") | |
| Write-Host "<showChart>1</showChart>" | |
| Write-Host "<showTable>1</showTable>" | |
| Write-Host "<LimitMaxError>0</LimitMaxError>" | |
| Write-Host "<LimitMode>1</LimitMode>" | |
| Write-Host "</result>" | |
| } | |
| } | |
| } | |
| Write-Host "</prtg>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment