Below, you'll find my quick solution. The code looks like this:
Invoke-Expression 'Invoke-CsManagementStoreReplication'
Write-Host "Invoking Replication, please wait until it's complete:" -fore Yellow
do
{
$result = Get-CsManagementStoreReplicationStatus | Select ReplicaFqdn, UpToDate
write-host -nonewline "." -Fore Yellow
sleep 3
} While ($result.UpToDate -ne "True")
Write-Host
Get-CsManagementStoreReplicationStatus | Select ReplicaFqdn, UpToDate
Write-Host
Write-Host "Replication has completed. Thank you for your patience." -Fore Green
Paste the above code into Notepad and save as ScriptName.ps1, and you can run it from any PS prompt. When you do, it will look like:
The script has invoked replication and is in a do-while loop, checking to see if replication is complete every 3 seconds. It will write a period every iteration to give the user an indication that is still running:
Once it detects that replication is completed, it will print out all the CMS replicas and their status:
It's just easier for me than typing in the commands and hitting up arrow and enter every few seconds to see if replication is complete. You can paste the code directly into a script if you wish, or wrap it as a function that you can call several times within your script:
Function Replicate-CMS{
Invoke-Expression 'Invoke-CsManagementStoreReplication'
Write-Host "Invoking Replication, please wait until it's complete:" -fore Yellow
do
{
$result = Get-CsManagementStoreReplicationStatus | Select ReplicaFqdn, UpToDate
write-host -nonewline "." -Fore Yellow
sleep 3
} While ($result.UpToDate -ne "True")
Write-Host
Get-CsManagementStoreReplicationStatus | Select ReplicaFqdn, UpToDate
Write-Host
Write-Host "Replication has completed. Thank you for your patience." -Fore Green
}
So, as you can see, this is a very simple script and makes it easy to invoke and track the status of replication.
I hope some of you out there will find this useful. If you do, please follow and comment. If you have any suggestions to improve this, I welcome the feedback.
No comments:
Post a Comment
Thanks for reading and commenting. I look forward to it.