Update function to use new token parameter
This commit is contained in:
@@ -6,21 +6,30 @@ function Add-ZertoPeerSite {
|
|||||||
Mandatory = $true,
|
Mandatory = $true,
|
||||||
HelpMessage = "Target Hostname or IP address to pair the localsite to."
|
HelpMessage = "Target Hostname or IP address to pair the localsite to."
|
||||||
)]
|
)]
|
||||||
[ValidateScript( {$_ -match [IPAddress]$_ } )]
|
[ValidateScript( { $_ -match [IPAddress]$_ } )]
|
||||||
[string]$targetHost,
|
[string]$targetHost,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Target communication port. Default is 9081"
|
HelpMessage = "Target communication port. Default is 9081"
|
||||||
)]
|
)]
|
||||||
[ValidateRange(1024, 65535)]
|
[ValidateRange(1024, 65535)]
|
||||||
[int]$targetPort = 9081
|
[int]$targetPort = 9081,
|
||||||
|
[Parameter(
|
||||||
|
HelpMessage = "The generated token from the destination site. Note: This is only supported when both sites support pairing authentication. This was implemented to support ZVR 7.5 and later."
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$token
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
$baseUri = "peersites"
|
|
||||||
$body = @{"HostName" = $targetHost; "Port" = $targetPort}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
$baseUri = "peersites"
|
||||||
|
if ($PSBoundParameters.Keys.Contains("token")) {
|
||||||
|
$body = @{ "HostName" = $targetHost; "Port" = $targetPort; "Token" = $token }
|
||||||
|
} else {
|
||||||
|
$body = @{ "HostName" = $targetHost; "Port" = $targetPort }
|
||||||
|
}
|
||||||
if ($PSCmdlet.ShouldProcess("Pairing with Site $targetHost")) {
|
if ($PSCmdlet.ShouldProcess("Pairing with Site $targetHost")) {
|
||||||
Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST"
|
Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user