Update New-ZertoVpgSettingsIdentifier.ps1
Set default Parameter Set, Move body creation to process block for pipeline processing.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function New-ZertoVpgSettingsIdentifier {
|
||||
[cmdletbinding( SupportsShouldProcess = $true )]
|
||||
[cmdletbinding( SupportsShouldProcess = $true, DefaultParameterSetName = "newVpg" )]
|
||||
param(
|
||||
[Parameter(
|
||||
HelpMessage = "Identifier of the VPG to create a VPG settings identifier. If a vpgIdentifier is not provided, a new VPG settings object is created without any configured settings. This would be used for creating a new VPG from scratch.",
|
||||
@@ -11,7 +11,7 @@ function New-ZertoVpgSettingsIdentifier {
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgId")]
|
||||
[string]$vpgIdentifier,
|
||||
[string[]]$vpgIdentifier,
|
||||
[Parameter(
|
||||
HelpMessage = "Use this switch when creating a vpgSettingsIdentifier for a new VPG",
|
||||
ParameterSetName = "newVpg",
|
||||
@@ -22,20 +22,24 @@ function New-ZertoVpgSettingsIdentifier {
|
||||
|
||||
begin {
|
||||
$baseUri = "vpgSettings"
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"newVpg" {
|
||||
$body = "{}"
|
||||
}
|
||||
|
||||
"existingVpg" {
|
||||
$body = "{""VpgIdentifier"":""$vpgIdentifier""}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"newVpg" {
|
||||
$body = "{}"
|
||||
if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
|
||||
}
|
||||
}
|
||||
"existingVpg" {
|
||||
foreach ($id in $vpgIdentifier) {
|
||||
$body = "{""VpgIdentifier"":""$id""}"
|
||||
if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user