Using Powershell to check ADAM replication

Hey folks, I wanted to share a powershell script I deployed at a customers. You will find this script useful for when checking the Horizon View Broker replication status along with the Global Entitlement replication health. Typically I would establish a RDP session into each broker and execute the repadmin command on each server, this automates that process. You will need to execute this script using View PowerCLI on a Horizon View Connection server.

<#

Name: “ViewShowADAMRep.ps1”

Purpose: This script is used to view the replication status of the ADAM database on each View Connection server.

Achieved by:

– Acquiring connection server names via user input variable

– Opening a new powershell session on a connection server

– Running a repadmin based command to show replication on the local system for the View related LDAP instance

Execution Option1 (Displays results on the screen only): ./ViewShowADAMRep.ps1

Execution Option2 (Dumps results into a textfile, Output.txt): ./ViewShowADAMRep.ps1 > Output.txt

Creator: Jeremy Wheeler

Date: 01/20/2016

#>

#Create connection servers variable and fill with desired connection servers.

#Remove the hashtag and replace ‘connectionserver##’ with your View Connection server information.

$connservers = @()

#$connservers += “connectionserver#1”

#$connservers += “connectionserver#2”

#$connservers += “connectionserver#3”

#$connservers += “connectionserver#4”

#$connservers += “connectionserver#5”

#$connservers += “connectionserver#6”

#$connservers += “connectionserver#7”

Write-Host “”

Write-Host ” – Testing broker ADAM Replication…”

Write “”

Write “**************************************************”

Write “***** Now testing broker ADAM Replication *****”

Write “**************************************************”

Write “”

#Loop through connection servers

foreach ($conn in $connservers) {

#Null reused variable

$session = $null

#Create new powershell session on remote system

$session = New-PSSession -ComputerName $conn

#Runs a powershell command on the remote system

Invoke-Command -Session $session -ScriptBlock {repadmin.exe /showrepl localhost:389 ‘DC=vdi,DC=vmware,DC=int’}

}

Write-Host ” – Testing Global Entitlement ADAM Replication…”

Write-Host “”

Write “”

Write “**************************************************************”

Write “***** Now testing Global Entitlement ADAM Replication *****”

Write “**************************************************************”

Write “”

#Loop through connection servers

foreach ($conn in $connservers) {

#Null reused variable

$session = $null

#Create new powershell session on remote system

$session = New-PSSession -ComputerName $conn

#Runs a powershell command on the remote system

Invoke-Command -Session $session -ScriptBlock {repadmin.exe /showrepl localhost:22389 ‘DC=vdiglobal,DC=vmware,DC=int’}

}

Write-Host “done.”

Write-Host “”

#Removes all live powershell sessions (aka. cleanup)

Get-PSSession | Remove-PSSession

Leave a Reply

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.