Update Invoke-ZertoMoveCommit.ps1
Add ShouldProcess Use switches instead of bools Prioritize Reverse Protect over KeepSourceVms
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||||
function Invoke-ZertoMoveCommit {
|
function Invoke-ZertoMoveCommit {
|
||||||
[cmdletbinding()]
|
[cmdletbinding(SupportsShouldProcess = $true)]
|
||||||
param(
|
param(
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Name(s) of the VPG(s) to commit.",
|
HelpMessage = "Name(s) of the VPG(s) to commit.",
|
||||||
@@ -10,7 +10,7 @@ function Invoke-ZertoMoveCommit {
|
|||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False"
|
HelpMessage = "Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False"
|
||||||
)]
|
)]
|
||||||
[bool]$reverseProtect,
|
[switch]$reverseProtection,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Use this switch to keep the source VMs. If not set, they will be destroyed."
|
HelpMessage = "Use this switch to keep the source VMs. If not set, they will be destroyed."
|
||||||
)]
|
)]
|
||||||
@@ -19,10 +19,11 @@ function Invoke-ZertoMoveCommit {
|
|||||||
|
|
||||||
begin {
|
begin {
|
||||||
$baseUri = "vpgs"
|
$baseUri = "vpgs"
|
||||||
if ($reverseProtect) {
|
$body = @{}
|
||||||
$body = @{"ReverseProtection" = $reverseProtect; "KeepSourceVms" = $keepSourceVms}
|
if ($reverseProtection) {
|
||||||
} else {
|
$body["ReverseProtection"] = $true
|
||||||
$body = @{"KeepSourceVms" = $keepSourceVms}
|
} elseif ($keepSourceVms) {
|
||||||
|
$body["KeepSourceVms"] = $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +34,9 @@ function Invoke-ZertoMoveCommit {
|
|||||||
Write-Error "VPG: $name not found. Please check the name and try again. Skipping."
|
Write-Error "VPG: $name not found. Please check the name and try again. Skipping."
|
||||||
} else {
|
} else {
|
||||||
$uri = "{0}/{1}/MoveCommit" -f $baseUri, $vpgId
|
$uri = "{0}/{1}/MoveCommit" -f $baseUri, $vpgId
|
||||||
Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST"
|
if ($PSCmdlet.ShouldProcess("Commiting VPG: $name with settings $($body | convertto-json)")) {
|
||||||
|
Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user