PaulNZ
Joined: 04 Apr 2017 Posts: 9
|
Posted: Wed May 03, 2017 6:24 pm Post subject: DFS Replication Backlog PowerShell Script |
|
|
Cobbled this together from some stuff I found online.
Name: PowerShell: Get DFS-R Backlog
Hint: Params: <Group Name> <Folder Name> <Sending Member> <Receiving Member> <Backlog Threshold>
Start cmd: powershell.exe %script% %params%
Script:
Code: | $statusAlive = "ScriptRes:Host is alive:"
$statusDead = "ScriptRes:No answer:"
$statusUnknown = "ScriptRes:Unknown:"
$statusNotResolved = "ScriptRes:Unknown host:"
$statusOk = "ScriptRes:Ok:"
$statusBad = "ScriptRes:Bad:"
$statusBadContents = "ScriptRes:Bad contents:"
if (!$args[4]) {
echo $statusUnknown"Insufficient parameters provided"
exit
}
$ReplicationGroupName = $args[0]
$ReplicatedFolderName = $args[1]
$Smem = $args[2]
$Rmem = $args[3]
$BacklogThreshold = $args[4]
$WMIQuery = "SELECT * FROM DfsrReplicatedFolderInfo WHERE ReplicationGroupName = '" + $ReplicationGroupName + "' AND ReplicatedFolderName = '" + $ReplicatedFolderName + "'"
$OutboundPartnerWMI = Get-WmiObject -computername $Smem -Namespace "root\MicrosoftDFS" -Query $WMIQuery
$InboundPartnerWMI = Get-WmiObject -computername $Rmem -Namespace "root\MicrosoftDFS" -Query $WMIQuery
$VersionVector = $InboundPartnerWMI.GetVersionVector().VersionVector
$BacklogCount = $OutboundPartnerWMI.GetOutboundBacklogFileCount($VersionVector).BacklogFileCount
if ($BacklogCount -le $BacklogThreshold)
{
echo $statusOk$BacklogCount" Files"
}
else
{
echo $statusBad$BacklogCount" Files"
} |
|
|