Update function to allow pipeline operations
This commit is contained in:
@@ -16,7 +16,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
|
|
||||||
Context "$($global:function)::Parameter Unit Tests" {
|
Context "$($global:function)::Parameter Unit Tests" {
|
||||||
It "Has a parameter for the VpgName that is Mandatory" {
|
It "Has a parameter for the VpgName that is Mandatory" {
|
||||||
Get-Command $global:function | Should -HaveParameter vpgName -Mandatory -Type String
|
Get-Command $global:function | Should -HaveParameter vpgName -Mandatory -Type 'String[]'
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Has a parameter for the CheckpointName that is Mandatory" {
|
It "Has a parameter for the CheckpointName that is Mandatory" {
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ function Checkpoint-ZertoVpg {
|
|||||||
param(
|
param(
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Mandatory = $true,
|
Mandatory = $true,
|
||||||
HelpMessage = "Name of the VPG to tag."
|
HelpMessage = "Name of the VPG to tag.",
|
||||||
|
ValueFromPipeline = $true,
|
||||||
|
ValueFromPipelineByPropertyName = $true
|
||||||
)]
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$vpgName,
|
[string[]]$vpgName,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Mandatory = $true,
|
Mandatory = $true,
|
||||||
HelpMessage = "Text to tag the checkpoint with."
|
HelpMessage = "Text to tag the checkpoint with."
|
||||||
@@ -18,16 +20,18 @@ function Checkpoint-ZertoVpg {
|
|||||||
|
|
||||||
begin {
|
begin {
|
||||||
$baseUri = "vpgs"
|
$baseUri = "vpgs"
|
||||||
$vpgIdentifier = $(get-zertovpg -name $vpgName).vpgIdentifier
|
|
||||||
$body = @{"checkpointName" = $checkpointName}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
if ($vpgIdentifier) {
|
foreach ($name in $vpgName) {
|
||||||
$uri = "{0}/{1}/Checkpoints" -f $baseUri, $vpgIdentifier
|
$vpgIdentifier = $(get-zertovpg -name $name).vpgIdentifier
|
||||||
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST"
|
if ($vpgIdentifier) {
|
||||||
} else {
|
$uri = "{0}/{1}/Checkpoints" -f $baseUri, $vpgIdentifier
|
||||||
Write-Output "Cannot find VPG named $vpgName. Please check the name and try again."
|
$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."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Add a tagged checkpoint to a specified VPG
|
|||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
```
|
```
|
||||||
Checkpoint-ZertoVpg [-vpgName] <String> [-checkpointName] <String> [<CommonParameters>]
|
Checkpoint-ZertoVpg [-vpgName] <String[]> [-checkpointName] <String> [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
@@ -49,14 +49,14 @@ Accept wildcard characters: False
|
|||||||
Name of the VPG to tag.
|
Name of the VPG to tag.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: String[]
|
||||||
Parameter Sets: (All)
|
Parameter Sets: (All)
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
Position: 0
|
Position: 0
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: True (ByPropertyName, ByValue)
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user