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 #>
|
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||||
function New-ZertoVpgSettingsIdentifier {
|
function New-ZertoVpgSettingsIdentifier {
|
||||||
[cmdletbinding( SupportsShouldProcess = $true )]
|
[cmdletbinding( SupportsShouldProcess = $true, DefaultParameterSetName = "newVpg" )]
|
||||||
param(
|
param(
|
||||||
[Parameter(
|
[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.",
|
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()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[Alias("vpgId")]
|
[Alias("vpgId")]
|
||||||
[string]$vpgIdentifier,
|
[string[]]$vpgIdentifier,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Use this switch when creating a vpgSettingsIdentifier for a new VPG",
|
HelpMessage = "Use this switch when creating a vpgSettingsIdentifier for a new VPG",
|
||||||
ParameterSetName = "newVpg",
|
ParameterSetName = "newVpg",
|
||||||
@@ -22,20 +22,24 @@ function New-ZertoVpgSettingsIdentifier {
|
|||||||
|
|
||||||
begin {
|
begin {
|
||||||
$baseUri = "vpgSettings"
|
$baseUri = "vpgSettings"
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
|
||||||
"newVpg" {
|
|
||||||
$body = "{}"
|
|
||||||
}
|
|
||||||
|
|
||||||
"existingVpg" {
|
|
||||||
$body = "{""VpgIdentifier"":""$vpgIdentifier""}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
|
"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