- This topic has 2 replies, 3 voices, and was last updated November 4, 2019 by Ooredoo P.
list of unprotected VMs
-
Israel TNovember 3, 2019 09:45:14 AM
we need to generate a list of unprotected VMs, do you have any way or Script to generate such List
Viola MNovember 4, 2019 02:34:29 AMHi,
Good day.
Regarding this question, it has already been asked in the Forums:
https://www.zerto.com/myzerto/forums/topic/export-list-of-unprotected-vms/
Content:
To get a list of unprotected VMs, you may want to look into using the Zerto APIs. The Resource Report or Volumes APIs may be most useful out of them.
Zerto Virtual Replication RESTful APIs: http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20RESTful%20APIs.pdf
Alternatively, if you can get a full list of APIs, you could export your VPG list, which will have all of your VMs listed with them, and compare the two lists with Excel. There is a built in system to detect duplicates.
Best Regards
Zerto Support
Ooredoo PNovember 4, 2019 06:39:26 AMmany thanks for prompt reply, but we are not expert with APIs or Zerto Scripts, can you provide us with tested script to generate the unprotected list of VMs.
we already used the following script to generate list of the protected VMs, but for unprotected we couldn’t, can you plz update the below script to generate the list of the unprotected VMs:
# Script variables
$ZertoServer = “tstzvm1”
$ZertoPort = “9669”
$ZertoUser = “tstadmin@vsphere.local”
$ZertoPassword = “DummyPassord”
# Setting Cert Policy
add-type @”
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
“@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
# Building Zerto API string and invoking API
$baseURL = “https://” + $ZertoServer + “:”+$ZertoPort+”/v1/”
# Authenticating with Zerto APIs
$xZertoSessionURI = $baseURL + “session/add”
$authInfo = (“{0}:{1}” -f $ZertoUser,$ZertoPassword)
$authInfo = [System.Text.Encoding]::UTF8.GetBytes($authInfo)
$authInfo = [System.Convert]::ToBase64String($authInfo)
$headers = @{Authorization=(“Basic {0}” -f $authInfo)}
$sessionBody = ‘{“AuthenticationMethod”: “1”}’
$contentType = “application/json”
$xZertoSessionResponse = Invoke-WebRequest -Uri $xZertoSessionURI -Headers $headers -Method POST -Body $sessionBody -ContentType $contentType
#Extracting x-zerto-session from the response, and adding it to the actual API
$xZertoSession = $xZertoSessionResponse.headers.get_item(“x-zerto-session”)
$zertSessionHeader = @{“x-zerto-session”=$xZertoSession}
# Querying API
$VMListURL = $BaseURL+”vms”
$VMList = Invoke-RestMethod -Uri $VMListURL -TimeoutSec 100 -Headers $zertSessionHeader -ContentType “application/JSON”
$VMListTable = $VMList | select VmName, VpgName, UsedStorageInMB, SourceSite, TargetSite, Priority
$VMListTable | format-table -AutoSize
# Selecting VPG name in table
$VMListTableFiltered | Where-Object VpgName -EQ “VMware-VPN” | format-table -AutoSize
The forum ‘Support Q & A’ is closed to new topics and replies.