From 69fb384c89577aaff09003e25c65cfb9fac3bd95 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 2 Apr 2020 15:12:43 -0400 Subject: [PATCH] Create Get-ZAProtectedVm.ps1 --- ZertoApiWrapper/Public/Get-ZAProtectedVm.ps1 | 50 ++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 ZertoApiWrapper/Public/Get-ZAProtectedVm.ps1 diff --git a/ZertoApiWrapper/Public/Get-ZAProtectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZAProtectedVm.ps1 new file mode 100644 index 0000000..8340275 --- /dev/null +++ b/ZertoApiWrapper/Public/Get-ZAProtectedVm.ps1 @@ -0,0 +1,50 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Get-ZAProtectedVm { + [cmdletbinding(DefaultParameterSetName = "AllVMs")] + param( + [Parameter( + ParameterSetName = "AllVMs", + HelpMessage = "Use this switch when you want a list of all protected VMs. Please be warned this list can be quite large." + )] + [switch]$AllVms, + [Parameter( + ParameterSetName = "IndividualVMs", + Mandatory, + HelpMessage = "A list of VM identifiers to query" + )] + [string[]]$VMIdentifier, + [Parameter( + ParameterSetName = "IndividualVMs", + HelpMessage = "Specify this switch when you would like protected vms' volume information returned" + )] + [switch]$Volumes + ) + + Begin { + + } + + Process { + $BaseUri = "monitoring/protected-vms" + switch ($PSCmdlet.ParameterSetName) { + "AllVMs" { + Invoke-ZARestRequest -uri $BaseUri + } + + "IndividualVMs" { + foreach ($identifier in $VMIdentifier) { + if ($Volumes.IsPresent) { + $Uri = "{0}/{1}/volumes" -f $BaseUri, $identifier + } else { + $uri = $Uri = "{0}/{1}" -f $BaseUri, $identifier + } + Invoke-ZARestRequest -uri $Uri + } + } + } + } + + End { + + } +}