Showing posts with label Zerto. Show all posts
Showing posts with label Zerto. Show all posts

Zerto Virtual Manager | Change Recovery VRA VM with powershell cmdlet

As a pre-requisite, you might need to download and install Zerto PowerShell Package from here


#Start here
clear
function LoadSnapin{
param($PSSnapinName)
if (!(Get-PSSnapin | where {$_.Name -eq $PSSnapinName})){
Add-pssnapin -name $PSSnapinName
}
}
# Loading snapins and modules
LoadSnapin -PSSnapinName "Zerto.PS.Commands"
clear
Write-host "Welcome to Zerto Powershell Script to change the Recovery VRA VMs one by one" -ForegroundColor Yellow
echo "################################ZERTO CMDLETS#####################################"
$ZVM =  read-host "Enter IP address of ZVM server "
Write-host "What is the full name of source host in vCenter Server? " -ForegroundColor yellow
$sourcehost = Read-host "Enter source host name "
Write-host "List of VMs is being extracted. Please bear with me." -ForegroundColor Green
Get-VMsReplicatingToHost -HostIp $sourcehost -ZVMIP $ZVM -ZVMPort 9080 -Username administrator -Password password

write-host "Which VM you want me to migrate? Select any VM in above list please  " -ForegroundColor Yellow
$VM = Read-Host "Enter VM Name "
Write-host "What is the full name of destination host in vCenter Server? " -ForegroundColor yellow
$desthost = Read-host "Enter destination host name "
Set-ChangeRecoveryHost -VMname $VM -CurrentTargetHost $sourcehost -NewTargetHost $desthost -ZVMIP $ZVM -ZVMport 9080 -username Administrator -password password -ErrorAction SilentlyContinue

Zerto Virtual Manager | Pause replication on all VPGs with CMDlets

It is simple, if you know it. Let's us powershell to do that.

function LoadSnapin{
param($PSSnapinName)
if (!(Get-PSSnapin | where {$_.Name -eq $PSSnapinName})){
Add-pssnapin -name $PSSnapinName
}
}
# Loading snapins and modules

LoadSnapin -PSSnapinName "Zerto.PS.Commands"

$VPGs = Get-ProtectionGroups -ZVMIP 1.1.1.1 -ZVMPort 9080 -Username administrator -Password password -SiteName ALL

#1.1.1.1 - ZVM Server IP
#9080 - ZVM port number
#administrator - username
#password - Password
#ALL - It is for all sites. Because service provider might have many sites connected to it.

foreach ($VPG in $VPGs){

Pause-ProtectionGroup -ZVMIP 172.22.2.30 -ZVMPort 9080 -Username administrator -Password password -ErrorAction SilentlyContinue -VirtualProtectionGroup $vpg -Confirm:$false
}

Please note: Run any script in your test environment first before applying into production. There is no harm in running above script but it is just an information :)

Zerto Virtual Manager | How to read xml file extracted from ZVM (Zerto Virtual Manager)

To explain it completely, let me share the thought behind this post-

In ZVM, when we recreate any VPG, we export its setting (Which include VMs name, IP settings, failover network, test network etc) before deleting it. So that, we don't need to create it from scratch and manually.

When we have this exported settings, we just import it back and VPG automatically get created. This setting which we export and import, does save in .xml file format.

In case, we don't export the settings before deleting any VPG then it is bit lengthy process to recreate it from scratch. Sometime it happens like we have exported the settings but now not able to import it back (due to n numbers of reasons).

In that case, now we have to recreate the VPG. But being in operations, it is not very easy to go to client and request to share all the details again or we sometime not comfortable to request client to recreate the VPG.

In that case, we need this exported .xml file, which we must know how to read it and write down all the setting of a VPG and the configure accordingly.

So hopefully, we got the essence, now let's proceed how to read .xml file

Note 1: .xml file content save in reverse order
Note 2:  name of VM, datastore and network, will be mentioned in UID format and not with general name as shown in vcenter server
Note 3:  read this .xml file in any web-browser rather than in notepad++ or any text editor application

Let's say I have a VPG named "VPG_11" and I have to read all its configuration from exported file.

I have created below you tube videos, just to make it simpler for me to explain. Any doubt, ask me..



Zerto Virtual Manager | How to read xml file part-I


Zerto Virtual Manager | How to read xml file part-II


Zerto Virtual Manager | How to read xml file part-III






Thank you,
Team vCloudnotes