Alan's Blog

"Yeah. I wrote a script that will do that."

Menu
  • About My Blog
Menu

Test Replication – A PowerShell Wrapper for RepAdmin

Posted on December 10, 2016January 18, 2017 by Alan

Repadmin is a standard tool in an AD admin’s toolbox, and “showrepl” displays the status of replication in your domain. The results of this command are quite verbose, and can make your eyes glaze over in late night troubleshooting.  A number of people have noticed that you can pipe RepAdmin CSV output to the ConvertFrom-CSV cmdlet in PowerShell. I wanted a little more than what others had done. The script below is my effort.  It (naturally) requires repadmin and the Out-Gridview cmdlet.

#Test-Replication
#Alan dot Kaplan at VA dot GOV
#11-21-2016
#Requires -version 3
Add-Type -assemblyname Microsoft.visualBasic

$bonlyFailures = $false
$FQDNExample = [system.net.dns]::GetHostEntry($env:computername).hostname
$msg = "This will check replication using repadmin. 
You may check a single DC, ex: $FQDNExample, or a all DCs in a domain, ex: *`.$env:userdnsdomain`."
$SearchScope = [Microsoft.VisualBasic.Interaction]::InputBox($msg, "Check Replication", "*`.$env:userdnsdomain")
if (!($searchScope)){Exit}

$msg = "1) Show all results
2) Show only errors
3) Exit"
$retval = [Microsoft.VisualBasic.Interaction]::InputBox($msg, "Errors Only?",2 )
switch ($retval)
{
    1 {$ShowIfGE = 0}
    2 {$ShowIfGE = 1}
    Default {Exit}
}


$props = "Source DSA,Source DSA Site,Destination DSA,Destination DSA Site,Naming Context,Number of Failures,Last Failure Status,Last Failure Time,Last Success Time,Transport Type".Split(",")
$retval = repadmin  /showrepl $searchscope /csv |
ConvertFrom-Csv |
Where {$_.'Number Of Failures' -ge $ShowIfGE} 
if ($retval){
    $retval |
    Select $props |
    Sort 'Source DSA', 'Destination DSA' |
    out-gridview -Title "Replication Status for $searchscope"
}ELSE{
    Write "No replication errors found for $searchscope"
}

Leave a Reply

You must be logged in to post a comment.

Search

Please Note

All the scripts are saved as .txt files. Newer files have a “View Script” button which will let you save or open a script in notepad. For earlier posts, the easiest way to download with IE is to right click on the link and use “Save Target As”. Rename file from Name_ext.txt to Name.ext.

To see a full post after searching, please click on the title.

PowerShell Scripts were written with version 3 or later.

https connections are supported.

All new users accounts must be approved, as are comments. Please be patient.  If you find a post error or a script which doesn’t work as expected, I appreciate being notified.  My email is my first name at the domain name, and you are welcome to contact me that way.

Tags

1E ACLS Active Directory ActiveDirectory ADSI Advanced Functions Audit Change Administrator Password COMObject Computer Groups DateTime Desktop DNS Excel FileScriptingObject Forms General GPO GPS Group Policy Hacks ISE Lockout logons NAV740 Nessus OU OU permissions Outlook Pick Folder Power PowerShell Powershell Scriptlets RDP SCCM schedule reboot Scripting Security Shell.Application user information VBA Windows Update WMI WordPress WPF

Categories

akaplan.com

  • Back to Home Page

Archives

Scripting Sites

  • A Big Pile of Small Things
  • Adam, the Automator
  • Art of the DBA
  • Ashley McGlone
  • Boe Prox
  • Carlo Mancini
  • DexterPOSH
  • Doug Finke
  • Jaap Brasser's Blog
  • JeffOps The Scripting Dutchman
  • Jonathan Medd's Blog
  • Keith Hill's Blog
  • LazyWinAdmin
  • Nana Lakshmanan
  • PowerShell Magazine
  • PowerShell Team Blog
  • PowerShell.org
  • PwrShell.net
  • Richard Siddaway's Blog
  • Ryan Yates' Blog
  • Skatterbrainz
  • The Lonely Administrator

SQL Site

  • Art of the DBA

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2025 Alan's Blog | Theme by SuperbThemes

Terms and Conditions - Privacy Policy