Update function to allow pipeline operations
This commit is contained in:
@@ -4,10 +4,12 @@ function Checkpoint-ZertoVpg {
|
||||
param(
|
||||
[Parameter(
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Name of the VPG to tag."
|
||||
HelpMessage = "Name of the VPG to tag.",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vpgName,
|
||||
[string[]]$vpgName,
|
||||
[Parameter(
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Text to tag the checkpoint with."
|
||||
@@ -18,16 +20,18 @@ function Checkpoint-ZertoVpg {
|
||||
|
||||
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."
|
||||
foreach ($name in $vpgName) {
|
||||
$vpgIdentifier = $(get-zertovpg -name $name).vpgIdentifier
|
||||
if ($vpgIdentifier) {
|
||||
$uri = "{0}/{1}/Checkpoints" -f $baseUri, $vpgIdentifier
|
||||
$body = @{"checkpointName" = $checkpointName}
|
||||
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST"
|
||||
} else {
|
||||
Write-Output "Cannot find VPG named $name. Please check the name and try again."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user