Update function to use new token parameter
This commit is contained in:
@@ -6,21 +6,30 @@ function Add-ZertoPeerSite {
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Target Hostname or IP address to pair the localsite to."
|
||||
)]
|
||||
[ValidateScript( {$_ -match [IPAddress]$_ } )]
|
||||
[ValidateScript( { $_ -match [IPAddress]$_ } )]
|
||||
[string]$targetHost,
|
||||
[Parameter(
|
||||
HelpMessage = "Target communication port. Default is 9081"
|
||||
)]
|
||||
[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 {
|
||||
$baseUri = "peersites"
|
||||
$body = @{"HostName" = $targetHost; "Port" = $targetPort}
|
||||
}
|
||||
|
||||
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")) {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user