diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverTest.ps1 index 0fbac3f..cc3d98f 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverTest.ps1 @@ -2,22 +2,45 @@ function Invoke-ZertoFailoverTest { [cmdletbinding()] param( [Parameter( - HelpMessage = "Name(s) of VPG(s) to roll back from failing over", + HelpMessage = "Name of VPG to failover test", Mandatory = $true )] - [string[]]$vpgName + [string]$vpgName, + [Parameter( + HelpMessage = "The identifier of the checkpoint to use for testing. If unspecified, the latest checkpoint will be used." + )] + [string]$checkpointIdentifier, + [Parameter( + HelpMessage = "The name(s) of the VMs within the selected VPG you wish to test. If unspecified, all VMs in the VPG will be tested." + )] + [string[]]$vmName ) begin { $baseUri = "vpgs" + $vpgIdentifier = $(Get-ZertoVpg -name $vpgName).vpgIdentifier + if ( $PSBoundParameters.ContainsKey('vmName') ) { + $vmIdentifiers = @() + $vmIdentifiers = foreach ( $name in $vmName ) { + $(Get-ZertoProtectedVm -vmName $name).vmIdentifier + } + } } process { - foreach ($name in $vpgName) { - $id = $(Get-ZertoVpg -name $name).vpgIdentifier - $uri = "{0}/{1}/FailoverTest" -f $baseUri, $id - Invoke-ZertoRestRequest -uri $uri -method "POST" + $uri = "{0}/{1}/FailoverTest" -f $baseUri, $vpgIdentifier + $body = [ordered]@{} + if ($checkpointIdentifier) { + $body['CheckpointIdentifier'] = $checkpointIdentifier } + if ( $PSBoundParameters.ContainsKey('vmName') ) { + $vmIdentifiers = @() + $vmIdentifiers = foreach ( $name in $vmName ) { + $(Get-ZertoProtectedVm -vmName $name).vmIdentifier + } + $body['VmIdentifiers'] = $vmIdentifiers + } + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) } end {