Hi,
I've recently started looking at the SRM API for PowerCLI and, can get some quiet basic information, e.g. I can list VM's contained in a Protection Group.
Below is a script that I've been able to plagiarize to do this for me
$cred = Get-Credential
Connect-VIServer $vc -Credential $cred
Connect-SrmServer | Out-null
# Get the Protection Group Information & create a folder to save the results to
$ProtectionGroupName = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the Name of the SRM Protection Group", "SRM Protection Group Name")
$ResultsFolder = New-Item -ItemType Directory -Path C:\Temp\$ProtectionGroupName -Force
$ResultsFile = "$Resultsfolder" + "\" + "$ProtectionGroupName" + " - " + (Get-Date -Format yyyy-MMM-dd-HHmm) + ".csv"
#Begin collecting data
$srmapi = $defaultsrmservers.ExtensionData
$srmpgs = $srmapi.protection.listprotectiongroups() | where {$_.GetInfo().Name -like "$ProtectionGroupName"} | Get-Unique
if (!($srmpgs))
{
Write-Host -ForegroundColor Red "Protection Group Name entered cannot be found"
Write-Host -ForegroundColor Red "Verify that you have entered a valid Protection Group Name. Exiting Script"
break
}
$pgvms =@()
$vms = $srmpgs.ListProtectedVMs()
for ($a=0; $a -lt $vms.Count; $a++)
{
$vm = get-vm -ID $vms[$a].VM.MoRef
$pgvms += $vm.Name
}
# sort the array alphabetically and enter the results into a .csv file
$pgvms = $pgvms | sort
Add-Content $ResultsFile $pgvms
# Disconnect from vCenter
Disconnect-VIServer $vc -Confirm:$false
# Open the .csv file
Invoke-Item $ResultsFile
I'd like to include extra information, Recovery Status, Priority, etc...
I've looked at the output from $srmapi.recovery, etc... but can't find what i'm looking for.
Anyone out there had any success with this already ?
Thanks