Added Checkpoint Creation and VPG Removal Functions

This commit is contained in:
Wes Carroll
2019-02-25 22:37:47 -05:00
parent f0e6c7c225
commit 20d947a931
2 changed files with 74 additions and 0 deletions
@@ -0,0 +1,34 @@
function Checkpoint-ZertoVpg {
[cmdletbinding()]
param(
[Parameter(
Mandatory = $true,
HelpMessage = "Name of the VPG to tag."
)]
[string]$vpgName,
[Parameter(
Mandatory = $true,
HelpMessage = "Text to tag the checkpoint with."
)]
[string]$checkpointName
)
begin {
$baseUri = "vpgs"
$vpgIdentifier = $(get-zertovpg -name $vpgName).vpgIdentifier
$body = @{"checkpointName" = $checkpointName}
}
process {
if ($vpgIdentifier) {
$uri = "{0}/{1}/Checkpoints" -f $baseUri, $vpgIdentifier
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST"
} else {
Write-Output "Cannot find VPG named $vpgName. Please check the name and try again."
}
}
end {
}
}
@@ -0,0 +1,40 @@
function Remove-ZertoVpg {
[cmdletbinding( SupportsShouldProcess = $true )]
param(
[Parameter(
Mandatory = $true,
HelpMessage = "Name of the VPG to delete."
)]
[string]$vpgName,
[Parameter(
HelpMessage = "Use this switch to keep the recovery volumes at the target site. If the virtual machines in the deleted VPG are reprotected, these volumes can be used as preseeded volumes to speed up the initial synchronization of the new VPG."
)]
[switch]$keepRecoveryVolumes,
[Parameter(
HelpMessage = "Use this switch to force delete the VPG."
)]
[switch]$force
)
begin {
$baseUri = "vpgs"
$vpgIdentifier = $(get-zertovpg -name $vpgName).vpgIdentifier
}
process {
$vpgIdentifier = $(get-zertovpg -name $vpgName).vpgIdentifier
if ( $vpgIdentifier ) {
$uri = "{0}/{1}" -f $baseUri, $vpgIdentifier
$body = @{"Force" = $force; "KeepRecoveryVolumes" = $keepRecoveryVolumes}
if ($PSCmdlet.ShouldProcess( $vpgName + " and these settings: " + $($body | ConvertTo-Json) ) ) {
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -Method "DELETE"
}
} else {
Write-Output "VPG with name $vpgName not found. Please check the name and try again"
}
}
end {
# Nothing to do
}
}